From cd3105b32020ab5ee774643b5be7c4466e148a8b Mon Sep 17 00:00:00 2001 From: elforjani13 <39470382+elforjani13@users.noreply.github.com> Date: Tue, 2 Nov 2021 00:23:43 +0200 Subject: [PATCH] feat: add Bad-debt & cancel bad-bebt. --- src/components/DialogsContainer.js | 2 +- ...{BadDebtAlert.js => CancelBadDebtAlert.js} | 17 +++-- .../Dialogs/BadDebtDialog/BadDebtForm.js | 2 +- .../Drawers/BillDrawer/BillDrawerDetails.js | 4 +- .../InvoiceDetailDrawer/BadDebtMenuItem.js | 70 ------------------- .../InvoiceDetailDrawer/InvoiceDetail.js | 4 +- .../InvoiceDetailActionsBar.js | 19 +++-- .../Drawers/InvoiceDetailDrawer/utils.js | 41 +++++++++++ .../InventoryItemDetails/utils.js | 2 +- .../Sales/Invoices/InvoicesAlerts.js | 6 +- src/hooks/query/invoices.js | 1 + src/lang/ar/index.json | 8 ++- src/lang/en/index.json | 10 ++- 13 files changed, 86 insertions(+), 100 deletions(-) rename src/containers/Alerts/Invoices/{BadDebtAlert.js => CancelBadDebtAlert.js} (77%) delete mode 100644 src/containers/Drawers/InvoiceDetailDrawer/BadDebtMenuItem.js diff --git a/src/components/DialogsContainer.js b/src/components/DialogsContainer.js index f1e803fff..1a31006dc 100644 --- a/src/components/DialogsContainer.js +++ b/src/components/DialogsContainer.js @@ -45,7 +45,7 @@ export default function DialogsContainer() { - + ); } diff --git a/src/containers/Alerts/Invoices/BadDebtAlert.js b/src/containers/Alerts/Invoices/CancelBadDebtAlert.js similarity index 77% rename from src/containers/Alerts/Invoices/BadDebtAlert.js rename to src/containers/Alerts/Invoices/CancelBadDebtAlert.js index b3d05c083..6bbe29994 100644 --- a/src/containers/Alerts/Invoices/BadDebtAlert.js +++ b/src/containers/Alerts/Invoices/CancelBadDebtAlert.js @@ -11,9 +11,9 @@ import withAlertActions from 'containers/Alert/withAlertActions'; import { compose } from 'utils'; /** - * bad debt alert. + * Cancel bad debt alert. */ -function BadDebtAlert({ +function CancelBadDebtAlert({ name, // #withAlertStoreConnect @@ -23,7 +23,7 @@ function BadDebtAlert({ // #withAlertActions closeAlert, }) { - // handle cancel alert. + // handle cancel alert. const handleCancel = () => { closeAlert(name); }; @@ -35,7 +35,7 @@ function BadDebtAlert({ cancelBadDebtMutate(invoiceId) .then(() => { AppToaster.show({ - message: intl.get('the_invoice_has_been_deleted_successfully'), + message: intl.get('badDebt_canceled_write_off_success_message'), intent: Intent.SUCCESS, }); }) @@ -48,7 +48,7 @@ function BadDebtAlert({ return ( } - confirmButtonText={} + confirmButtonText={} intent={Intent.WARNING} isOpen={isOpen} onCancel={handleCancel} @@ -56,10 +56,13 @@ function BadDebtAlert({ loading={isLoading} >

- +

); } -export default compose(withAlertStoreConnect(), withAlertActions)(BadDebtAlert); +export default compose( + withAlertStoreConnect(), + withAlertActions, +)(CancelBadDebtAlert); diff --git a/src/containers/Dialogs/BadDebtDialog/BadDebtForm.js b/src/containers/Dialogs/BadDebtDialog/BadDebtForm.js index 5b579db28..bd2d7696e 100644 --- a/src/containers/Dialogs/BadDebtDialog/BadDebtForm.js +++ b/src/containers/Dialogs/BadDebtDialog/BadDebtForm.js @@ -50,7 +50,7 @@ function BadDebtForm({ // Handle request response success. const onSuccess = (response) => { AppToaster.show({ - message: intl.get('badDebt_success_message'), + message: intl.get('badDebt_writte_off_success_message'), intent: Intent.SUCCESS, }); closeDialog(dialogName); diff --git a/src/containers/Drawers/BillDrawer/BillDrawerDetails.js b/src/containers/Drawers/BillDrawer/BillDrawerDetails.js index 4b72212da..8369fb7b8 100644 --- a/src/containers/Drawers/BillDrawer/BillDrawerDetails.js +++ b/src/containers/Drawers/BillDrawer/BillDrawerDetails.js @@ -38,11 +38,11 @@ export default function BillDrawerDetails() { id={'landed_cost'} panel={} /> - + /> */} ); diff --git a/src/containers/Drawers/InvoiceDetailDrawer/BadDebtMenuItem.js b/src/containers/Drawers/InvoiceDetailDrawer/BadDebtMenuItem.js deleted file mode 100644 index ea86bd2f7..000000000 --- a/src/containers/Drawers/InvoiceDetailDrawer/BadDebtMenuItem.js +++ /dev/null @@ -1,70 +0,0 @@ -import React from 'react'; -import { - Button, - NavbarGroup, - Classes, - NavbarDivider, - Popover, - PopoverInteractionKind, - Position, - Intent, - MenuItem, - Menu, -} from '@blueprintjs/core'; -import { If, Icon, FormattedMessage as T } from 'components'; -import { useInvoiceDetailDrawerContext } from './InvoiceDetailDrawerProvider'; - -import withDialogActions from 'containers/Dialog/withDialogActions'; -import withAlertsActions from 'containers/Alert/withAlertActions'; - -import { compose } from 'utils'; - -function BadDebtMenuItem({ - // #withDialogActions - openDialog, - - // #withAlertsActions - openAlert, -}) { - // Invoice detail drawer context. - const { invoiceId, invoice } = useInvoiceDetailDrawerContext(); - - const handleBadDebtInvoiceDialog = () => { - openDialog('invoice-bad-debt', { invoiceId }); - }; - - const handleBadDebtInvoiceAlert = () => { - openAlert('bad-debt', { invoiceId }); - }; - - return ( - - - } - onClick={handleBadDebtInvoiceAlert} - /> - - - } - /> - - } - minimal={true} - interactionKind={PopoverInteractionKind.CLICK} - position={Position.BOTTOM_LEFT} - canOutsideClickClose={false} - usePortal={false} - modifiers={{ - offset: { offset: '0, 4' }, - }} - > -