mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
wip
This commit is contained in:
@@ -3,7 +3,6 @@ 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 { useBulkDeleteAccounts } from '@/hooks/query/accounts';
|
||||
@@ -45,7 +44,6 @@ function AccountBulkDeleteDialog({
|
||||
message: intl.get('the_accounts_has_been_successfully_deleted'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('accounts-table');
|
||||
setAccountsSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ 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 { useBulkDeleteBills } from '@/hooks/query/bills';
|
||||
@@ -44,7 +43,6 @@ function BillBulkDeleteDialog({
|
||||
message: intl.get('the_bills_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('bills-table');
|
||||
setBillsSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ 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';
|
||||
@@ -45,7 +44,6 @@ function CreditNoteBulkDeleteDialog({
|
||||
message: intl.get('the_credit_notes_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('credit-notes-table');
|
||||
setCreditNotesSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
// @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 BulkDeleteDialogContent from '@/containers/Dialogs/components/BulkDeleteDialogContent';
|
||||
import { useBulkDeleteCustomers } from '@/hooks/query/customers';
|
||||
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import withCustomersActions from '@/containers/Customers/CustomersLanding/withCustomersActions';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
function CustomerBulkDeleteDialog({
|
||||
dialogName,
|
||||
isOpen,
|
||||
payload: {
|
||||
ids = [],
|
||||
deletableCount = 0,
|
||||
undeletableCount = 0,
|
||||
totalSelected = ids.length,
|
||||
} = {},
|
||||
|
||||
// #withCustomersActions
|
||||
setCustomersSelectedRows,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { mutateAsync: bulkDeleteCustomers, isLoading } =
|
||||
useBulkDeleteCustomers();
|
||||
|
||||
const handleCancel = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
const handleConfirmBulkDelete = () => {
|
||||
bulkDeleteCustomers({
|
||||
ids,
|
||||
skipUndeletable: true,
|
||||
})
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('the_customers_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
setCustomersSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
.catch(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('something_went_wrong'),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title={
|
||||
<T
|
||||
id={'bulk_delete_dialog_title'}
|
||||
values={{ resourcePlural: intl.get('resource_customer_plural') }}
|
||||
/>
|
||||
}
|
||||
isOpen={isOpen}
|
||||
onClose={handleCancel}
|
||||
canEscapeKeyClose={!isLoading}
|
||||
canOutsideClickClose={!isLoading}
|
||||
>
|
||||
<BulkDeleteDialogContent
|
||||
totalSelected={totalSelected}
|
||||
deletableCount={deletableCount}
|
||||
undeletableCount={undeletableCount}
|
||||
resourceSingularLabel={intl.get('resource_customer_singular')}
|
||||
resourcePluralLabel={intl.get('resource_customer_plural')}
|
||||
/>
|
||||
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<Button onClick={handleCancel} disabled={isLoading}>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
intent={Intent.DANGER}
|
||||
onClick={handleConfirmBulkDelete}
|
||||
loading={isLoading}
|
||||
disabled={deletableCount === 0 || isLoading}
|
||||
>
|
||||
<T id={'delete_count'} values={{ count: deletableCount }} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogRedux(),
|
||||
withDialogActions,
|
||||
withCustomersActions,
|
||||
)(CustomerBulkDeleteDialog);
|
||||
|
||||
@@ -3,7 +3,6 @@ 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 { useBulkDeleteEstimates } from '@/hooks/query/estimates';
|
||||
@@ -45,7 +44,6 @@ function EstimateBulkDeleteDialog({
|
||||
message: intl.get('the_estimates_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('estimates-table');
|
||||
setEstimatesSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ 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 { useBulkDeleteExpenses } from '@/hooks/query/expenses';
|
||||
@@ -45,7 +44,6 @@ function ExpenseBulkDeleteDialog({
|
||||
message: intl.get('the_expenses_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('expenses-table');
|
||||
setExpensesSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ import React from 'react';
|
||||
import { FormattedMessage as T } from '@/components';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Button, Classes, Dialog, Intent } from '@blueprintjs/core';
|
||||
import { queryCache } from 'react-query';
|
||||
|
||||
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
@@ -50,7 +49,6 @@ function InvoiceBulkDeleteDialog({
|
||||
message: intl.get('the_invoices_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('invoices-table');
|
||||
resetInvoicesSelectedRows();
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// @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 BulkDeleteDialogContent from '@/containers/Dialogs/components/BulkDeleteDialogContent';
|
||||
import { useBulkDeleteItems } from '@/hooks/query/items';
|
||||
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import withItemsActions from '@/containers/Items/withItemsActions';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
function ItemBulkDeleteDialog({
|
||||
dialogName,
|
||||
isOpen,
|
||||
payload: {
|
||||
ids = [],
|
||||
deletableCount = 0,
|
||||
undeletableCount = 0,
|
||||
totalSelected = ids.length,
|
||||
} = {},
|
||||
|
||||
// #withItemsActions
|
||||
setItemsSelectedRows,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { mutateAsync: bulkDeleteItems, isLoading } = useBulkDeleteItems();
|
||||
|
||||
const handleCancel = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
const handleConfirmBulkDelete = () => {
|
||||
bulkDeleteItems({
|
||||
ids,
|
||||
skipUndeletable: true,
|
||||
})
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('the_items_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
setItemsSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
.catch(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('something_went_wrong'),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title={
|
||||
<T
|
||||
id={'bulk_delete_dialog_title'}
|
||||
values={{ resourcePlural: intl.get('resource_item_plural') }}
|
||||
/>
|
||||
}
|
||||
isOpen={isOpen}
|
||||
onClose={handleCancel}
|
||||
canEscapeKeyClose={!isLoading}
|
||||
canOutsideClickClose={!isLoading}
|
||||
>
|
||||
<BulkDeleteDialogContent
|
||||
totalSelected={totalSelected}
|
||||
deletableCount={deletableCount}
|
||||
undeletableCount={undeletableCount}
|
||||
resourceSingularLabel={intl.get('resource_item_singular')}
|
||||
resourcePluralLabel={intl.get('resource_item_plural')}
|
||||
/>
|
||||
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<Button onClick={handleCancel} disabled={isLoading}>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
intent={Intent.DANGER}
|
||||
onClick={handleConfirmBulkDelete}
|
||||
loading={isLoading}
|
||||
disabled={deletableCount === 0 || isLoading}
|
||||
>
|
||||
<T id={'delete_count'} values={{ count: deletableCount }} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogRedux(),
|
||||
withDialogActions,
|
||||
withItemsActions,
|
||||
)(ItemBulkDeleteDialog);
|
||||
|
||||
@@ -3,7 +3,6 @@ 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 { useBulkDeleteManualJournals } from '@/hooks/query/manualJournals';
|
||||
@@ -45,7 +44,6 @@ function ManualJournalBulkDeleteDialog({
|
||||
message: intl.get('the_journals_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('manual-journals-table');
|
||||
setManualJournalsSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ 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 { useBulkDeletePaymentReceives } from '@/hooks/query/paymentReceives';
|
||||
@@ -47,7 +46,6 @@ function PaymentReceivedBulkDeleteDialog({
|
||||
),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('payments-received-table');
|
||||
setPaymentReceivesSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ 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 { useBulkDeleteReceipts } from '@/hooks/query/receipts';
|
||||
@@ -45,7 +44,6 @@ function ReceiptBulkDeleteDialog({
|
||||
message: intl.get('the_receipts_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('sale-receipts-table');
|
||||
setReceiptsSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -3,7 +3,6 @@ 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 { useBulkDeleteVendorCredits } from '@/hooks/query/vendorCredit';
|
||||
@@ -47,7 +46,6 @@ function VendorCreditBulkDeleteDialog({
|
||||
),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.invalidateQueries('vendor-credits-table');
|
||||
setVendorsCreditNoteSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
// @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 BulkDeleteDialogContent from '@/containers/Dialogs/components/BulkDeleteDialogContent';
|
||||
import { useBulkDeleteVendors } from '@/hooks/query/vendors';
|
||||
import withDialogRedux from '@/components/DialogReduxConnect';
|
||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||
import withVendorsActions from '@/containers/Vendors/VendorsLanding/withVendorsActions';
|
||||
import { compose } from '@/utils';
|
||||
|
||||
function VendorBulkDeleteDialog({
|
||||
dialogName,
|
||||
isOpen,
|
||||
payload: {
|
||||
ids = [],
|
||||
deletableCount = 0,
|
||||
undeletableCount = 0,
|
||||
totalSelected = ids.length,
|
||||
} = {},
|
||||
|
||||
// #withVendorsActions
|
||||
setVendorsSelectedRows,
|
||||
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const { mutateAsync: bulkDeleteVendors, isLoading } = useBulkDeleteVendors();
|
||||
|
||||
const handleCancel = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
const handleConfirmBulkDelete = () => {
|
||||
bulkDeleteVendors({
|
||||
ids,
|
||||
skipUndeletable: true,
|
||||
})
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('the_vendors_has_been_deleted_successfully'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
setVendorsSelectedRows([]);
|
||||
closeDialog(dialogName);
|
||||
})
|
||||
.catch(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('something_went_wrong'),
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
title={
|
||||
<T
|
||||
id={'bulk_delete_dialog_title'}
|
||||
values={{ resourcePlural: intl.get('resource_vendor_plural') }}
|
||||
/>
|
||||
}
|
||||
isOpen={isOpen}
|
||||
onClose={handleCancel}
|
||||
canEscapeKeyClose={!isLoading}
|
||||
canOutsideClickClose={!isLoading}
|
||||
>
|
||||
<BulkDeleteDialogContent
|
||||
totalSelected={totalSelected}
|
||||
deletableCount={deletableCount}
|
||||
undeletableCount={undeletableCount}
|
||||
resourceSingularLabel={intl.get('resource_vendor_singular')}
|
||||
resourcePluralLabel={intl.get('resource_vendor_plural')}
|
||||
/>
|
||||
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<Button onClick={handleCancel} disabled={isLoading}>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
intent={Intent.DANGER}
|
||||
onClick={handleConfirmBulkDelete}
|
||||
loading={isLoading}
|
||||
disabled={deletableCount === 0 || isLoading}
|
||||
>
|
||||
<T id={'delete_count'} values={{ count: deletableCount }} />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withDialogRedux(),
|
||||
withDialogActions,
|
||||
withVendorsActions,
|
||||
)(VendorBulkDeleteDialog);
|
||||
|
||||
Reference in New Issue
Block a user