This commit is contained in:
Ahmed Bouhuolia
2025-11-19 22:59:30 +02:00
parent 2b384b2f6f
commit 5eafd23bf8
75 changed files with 1986 additions and 826 deletions

View File

@@ -18,10 +18,6 @@ const ReconcileCreditDeleteAlert = React.lazy(
import('@/containers/Alerts/CreditNotes/ReconcileCreditNoteDeleteAlert'),
);
const CreditNoteBulkDeleteAlert = React.lazy(
() => import('@/containers/Alerts/CreditNotes/CreditNoteBulkDeleteAlert'),
);
/**
* Credit notes alerts.
*/
@@ -42,8 +38,4 @@ export default [
name: 'reconcile-credit-delete',
component: ReconcileCreditDeleteAlert,
},
{
name: 'credit-notes-bulk-delete',
component: CreditNoteBulkDeleteAlert,
},
];

View File

@@ -36,11 +36,11 @@ import withSettings from '@/containers/Settings/withSettings';
import withSettingsActions from '@/containers/Settings/withSettingsActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import withDrawerActions from '@/containers/Drawer/withDrawerActions';
import withAlertActions from '@/containers/Alert/withAlertActions';
import { DialogsName } from '@/constants/dialogs';
import { compose } from '@/utils';
import { DRAWERS } from '@/constants/drawers';
import { useBulkDeleteCreditNotesDialog } from './hooks/use-bulk-delete-credit-notes-dialog';
/**
* Credit note table actions bar.
@@ -64,9 +64,6 @@ function CreditNotesActionsBar({
// #withDrawerActions
openDrawer,
// #withAlertActions
openAlert,
}) {
const history = useHistory();
@@ -111,10 +108,15 @@ function CreditNotesActionsBar({
openDrawer(DRAWERS.BRANDING_TEMPLATES, { resource: 'CreditNote' });
}
const {
openBulkDeleteDialog,
isValidatingBulkDeleteCreditNotes,
} = useBulkDeleteCreditNotesDialog();
// Show bulk delete button when rows are selected.
if (!isEmpty(creditNotesSelectedRows)) {
const handleBulkDelete = () => {
openAlert('credit-notes-bulk-delete', { creditNotesIds: creditNotesSelectedRows });
openBulkDeleteDialog(creditNotesSelectedRows);
};
return (
<DashboardActionsBar>
@@ -125,6 +127,7 @@ function CreditNotesActionsBar({
text={<T id={'delete'} />}
intent={Intent.DANGER}
onClick={handleBulkDelete}
disabled={isValidatingBulkDeleteCreditNotes}
/>
</NavbarGroup>
</DashboardActionsBar>
@@ -231,5 +234,4 @@ export default compose(
})),
withDialogActions,
withDrawerActions,
withAlertActions,
)(CreditNotesActionsBar);

View File

@@ -0,0 +1,20 @@
// @ts-nocheck
import { DialogsName } from '@/constants/dialogs';
import { useValidateBulkDeleteCreditNotes } from '@/hooks/query/creditNote';
import { useBulkDeleteDialog } from '@/hooks/dialogs/useBulkDeleteDialog';
export const useBulkDeleteCreditNotesDialog = () => {
const validateBulkDeleteMutation = useValidateBulkDeleteCreditNotes();
const {
openBulkDeleteDialog,
closeBulkDeleteDialog,
isValidatingBulkDelete,
} = useBulkDeleteDialog(DialogsName.CreditNoteBulkDelete, validateBulkDeleteMutation);
return {
openBulkDeleteDialog,
closeBulkDeleteDialog,
isValidatingBulkDeleteCreditNotes: isValidatingBulkDelete,
};
};