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

@@ -14,10 +14,6 @@ const EstimateRejectAlert = React.lazy(
() => import('@/containers/Alerts/Estimates/EstimateRejectAlert'),
);
const EstimateBulkDeleteAlert = React.lazy(
() => import('@/containers/Alerts/Estimates/EstimateBulkDeleteAlert'),
);
/**
* Estimates alert.
*/
@@ -26,5 +22,4 @@ export default [
{ name: 'estimate-deliver', component: EstimateDeliveredAlert },
{ name: 'estimate-Approve', component: EstimateApproveAlert },
{ name: 'estimate-reject', component: EstimateRejectAlert },
{ name: 'estimates-bulk-delete', component: EstimateBulkDeleteAlert },
];

View File

@@ -33,11 +33,13 @@ import withEstimatesActions from './withEstimatesActions';
import withSettings from '@/containers/Settings/withSettings';
import withSettingsActions from '@/containers/Settings/withSettingsActions';
import withDialogActions from '@/containers/Dialog/withDialogActions';
import withAlertActions from '@/containers/Alert/withAlertActions';
import { useEstimatesListContext } from './EstimatesListProvider';
import { useRefreshEstimates } from '@/hooks/query/estimates';
import {
useRefreshEstimates,
} from '@/hooks/query/estimates';
import { useDownloadExportPdf } from '@/hooks/query/FinancialReports/use-export-pdf';
import { useBulkDeleteEstimatesDialog } from './hooks/use-bulk-delete-estimates-dialog';
import { SaleEstimateAction, AbilitySubject } from '@/constants/abilityOption';
import { compose } from '@/utils';
@@ -72,9 +74,6 @@ function EstimateActionsBar({
// #withSettingsActions
addSetting,
// #withAlertActions
openAlert,
}) {
const history = useHistory();
@@ -122,13 +121,16 @@ function EstimateActionsBar({
openDrawer(DRAWERS.BRANDING_TEMPLATES, { resource: 'SaleEstimate' });
};
const {
openBulkDeleteDialog,
isValidatingBulkDeleteEstimates,
} = useBulkDeleteEstimatesDialog();
// Handle bulk estimates delete.
const handleBulkDelete = () => {
openAlert('estimates-bulk-delete', { estimatesIds: estimatesSelectedRows });
openBulkDeleteDialog(estimatesSelectedRows);
};
console.log(estimatesSelectedRows, 'estimatesSelectedRows');
if (!isEmpty(estimatesSelectedRows)) {
return (
<DashboardActionsBar>
@@ -139,6 +141,7 @@ function EstimateActionsBar({
text={<T id={'delete'} />}
intent={Intent.DANGER}
onClick={handleBulkDelete}
disabled={isValidatingBulkDeleteEstimates}
/>
</NavbarGroup>
</DashboardActionsBar>
@@ -238,7 +241,6 @@ function EstimateActionsBar({
export default compose(
withEstimatesActions,
withSettingsActions,
withAlertActions,
withEstimates(({ estimatesTableState, estimatesSelectedRows }) => ({
estimatesFilterRoles: estimatesTableState.filterRoles,
estimatesSelectedRows: estimatesSelectedRows || [],

View File

@@ -0,0 +1,20 @@
// @ts-nocheck
import { DialogsName } from '@/constants/dialogs';
import { useValidateBulkDeleteEstimates } from '@/hooks/query/estimates';
import { useBulkDeleteDialog } from '@/hooks/dialogs/useBulkDeleteDialog';
export const useBulkDeleteEstimatesDialog = () => {
const validateBulkDeleteMutation = useValidateBulkDeleteEstimates();
const {
openBulkDeleteDialog,
closeBulkDeleteDialog,
isValidatingBulkDelete,
} = useBulkDeleteDialog(DialogsName.EstimateBulkDelete, validateBulkDeleteMutation);
return {
openBulkDeleteDialog,
closeBulkDeleteDialog,
isValidatingBulkDeleteEstimates: isValidatingBulkDelete,
};
};