mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
wip
This commit is contained in:
@@ -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,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user