// @ts-nocheck
import React from 'react';
import { Button, Classes, Dialog, Intent } from '@blueprintjs/core';
import { FormattedMessage as T, AppToaster } from '@/components';
import intl from 'react-intl-universal';
import { queryCache } from 'react-query';
import BulkDeleteDialogContent from '@/containers/Dialogs/components/BulkDeleteDialogContent';
import { useBulkDeleteCreditNotes } from '@/hooks/query/creditNote';
import withDialogRedux from '@/components/DialogReduxConnect';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import withCreditNotesActions from '@/containers/Sales/CreditNotes/CreditNotesLanding/withCreditNotesActions';
import { compose } from '@/utils';
function CreditNoteBulkDeleteDialog({
dialogName,
isOpen,
payload: {
ids = [],
deletableCount = 0,
undeletableCount = 0,
totalSelected = ids.length,
} = {},
// #withCreditNotesActions
setCreditNotesSelectedRows,
// #withDialogActions
closeDialog,
}) {
const { mutateAsync: bulkDeleteCreditNotes, isLoading } =
useBulkDeleteCreditNotes();
const handleCancel = () => {
closeDialog(dialogName);
};
const handleConfirmBulkDelete = () => {
bulkDeleteCreditNotes({
ids,
skipUndeletable: true,
})
.then(() => {
AppToaster.show({
message: intl.get('the_credit_notes_has_been_deleted_successfully'),
intent: Intent.SUCCESS,
});
queryCache.invalidateQueries('credit-notes-table');
setCreditNotesSelectedRows([]);
closeDialog(dialogName);
})
.catch(() => {
AppToaster.show({
message: intl.get('something_went_wrong'),
intent: Intent.DANGER,
});
});
};
return (
}
isOpen={isOpen}
onClose={handleCancel}
canEscapeKeyClose={!isLoading}
canOutsideClickClose={!isLoading}
>