From e8458e2b36477d1ac3d6aa81aba0fc8f1d0c842a Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Mon, 15 Feb 2021 16:23:58 +0200 Subject: [PATCH] refactoring: invoice form. refactoring: receipt form. refactoring: bill form. refactoring: estimate form. --- .../Alerts/Estimates/EstimateApproveAlert.js | 4 - .../Alerts/Estimates/EstimateDeleteAlert.js | 10 +- .../Estimates/EstimateDeliveredAlert.js | 16 +- .../Bills/BillForm/BillFloatingActions.js | 3 - .../Purchases/Bills/BillForm/BillForm.js | 64 +--- .../Purchases/Bills/BillForm/BillFormBody.js | 14 - .../Bills/BillForm/BillFormHeaderFields.js | 19 +- .../Bills/BillForm/BillFormProvider.js | 3 + .../Bills/BillForm/BillItemsEntriesEditor.js | 28 ++ .../Purchases/Bills/BillForm/utils.js | 39 +++ .../EstimateForm/EntriesItemsTable.js | 276 ------------------ .../EstimateForm/EstimateFloatingActions.js | 9 +- .../Estimates/EstimateForm/EstimateForm.js | 70 +---- .../EstimateForm/EstimateFormBody.js | 15 - .../EstimateForm/EstimateFormHeaderFields.js | 4 - .../EstimateForm/EstimateFormPage.js | 37 +-- .../EstimateForm/EstimateFormProvider.js | 16 +- .../EstimateForm/EstimateItemsEntriesField.js | 27 ++ .../EstimateForm/EstimateNumberWatcher.js | 46 --- .../Sales/Estimates/EstimateForm/utils.js | 38 +++ .../Estimates/EstimatesLanding/components.js | 4 + .../Sales/Invoices/InvoiceForm/InvoiceForm.js | 18 +- .../Sales/Invoices/InvoiceForm/constants.js | 26 -- .../Sales/Invoices/InvoiceForm/utils.js | 35 ++- .../Sales/Receipts/ReceiptForm/ReceiptForm.js | 62 +--- .../Receipts/ReceiptForm/ReceiptFormBody.js | 20 -- .../ReceiptForm/ReceiptFormProvider.js | 3 + .../ReceiptForm/ReceiptItemsEntriesEditor.js | 28 ++ .../ReceiptForm/ReceiptNumberWatcher.js | 45 --- .../Sales/Receipts/ReceiptForm/utils.js | 41 +++ client/src/hooks/query/bills.js | 7 +- client/src/hooks/query/estimates.js | 4 +- client/src/hooks/query/invoices.js | 11 +- client/src/hooks/query/receipts.js | 2 +- client/src/routes/dashboard.js | 46 +-- client/src/static/json/icons.js | 14 +- .../style/pages/SaleEstimate/PageForm.scss | 209 ++----------- 37 files changed, 410 insertions(+), 903 deletions(-) delete mode 100644 client/src/containers/Purchases/Bills/BillForm/BillFormBody.js create mode 100644 client/src/containers/Purchases/Bills/BillForm/BillItemsEntriesEditor.js create mode 100644 client/src/containers/Purchases/Bills/BillForm/utils.js delete mode 100644 client/src/containers/Sales/Estimates/EstimateForm/EntriesItemsTable.js delete mode 100644 client/src/containers/Sales/Estimates/EstimateForm/EstimateFormBody.js create mode 100644 client/src/containers/Sales/Estimates/EstimateForm/EstimateItemsEntriesField.js delete mode 100644 client/src/containers/Sales/Estimates/EstimateForm/EstimateNumberWatcher.js create mode 100644 client/src/containers/Sales/Estimates/EstimateForm/utils.js delete mode 100644 client/src/containers/Sales/Invoices/InvoiceForm/constants.js delete mode 100644 client/src/containers/Sales/Receipts/ReceiptForm/ReceiptFormBody.js create mode 100644 client/src/containers/Sales/Receipts/ReceiptForm/ReceiptItemsEntriesEditor.js delete mode 100644 client/src/containers/Sales/Receipts/ReceiptForm/ReceiptNumberWatcher.js create mode 100644 client/src/containers/Sales/Receipts/ReceiptForm/utils.js diff --git a/client/src/containers/Alerts/Estimates/EstimateApproveAlert.js b/client/src/containers/Alerts/Estimates/EstimateApproveAlert.js index affd3136e..53cd9f52a 100644 --- a/client/src/containers/Alerts/Estimates/EstimateApproveAlert.js +++ b/client/src/containers/Alerts/Estimates/EstimateApproveAlert.js @@ -21,9 +21,6 @@ function EstimateApproveAlert({ isOpen, payload: { estimateId }, - // #withEstimateActions - requestApproveEstimate, - // #withAlertActions closeAlert, }) { @@ -59,7 +56,6 @@ function EstimateApproveAlert({ } confirmButtonText={} - icon="trash" intent={Intent.WARNING} isOpen={isOpen} loading={isLoading} diff --git a/client/src/containers/Alerts/Estimates/EstimateDeleteAlert.js b/client/src/containers/Alerts/Estimates/EstimateDeleteAlert.js index 491a97ce9..b09f38a23 100644 --- a/client/src/containers/Alerts/Estimates/EstimateDeleteAlert.js +++ b/client/src/containers/Alerts/Estimates/EstimateDeleteAlert.js @@ -31,12 +31,12 @@ function EstimateDeleteAlert({ const { mutateAsync: deleteEstimateMutate, isLoading } = useDeleteEstimate(); // handle cancel delete alert. - const handleCancelEstimateDelete = () => { + const handleAlertCancel = () => { closeAlert(name); }; // handle confirm delete estimate - const handleConfirmEstimateDelete = useCallback(() => { + const handleAlertConfirm = () => { deleteEstimateMutate(estimateId) .then(() => { AppToaster.show({ @@ -50,7 +50,7 @@ function EstimateDeleteAlert({ .finally(() => { closeAlert(name); }); - }, [deleteEstimateMutate, name, closeAlert, formatMessage, estimateId]); + }; return (

{ + const handleAlertCancel = () => { closeAlert(name); }; // Handle confirm estimate delivered. - const handleConfirmEstimateDelivered = useCallback(() => { + const handleAlertConfirm = () => { deliverEstimateMutate(estimateId) .then(() => { AppToaster.show({ @@ -41,14 +40,13 @@ function EstimateDeliveredAlert({ id: 'the_estimate_has_been_delivered_successfully', }), intent: Intent.SUCCESS, - }); - queryCache.invalidateQueries('estimates-table'); + }) }) .catch((error) => {}) .finally(() => { closeAlert(name); }); - }, [estimateId, deliverEstimateMutate, formatMessage]); + }; return ( } intent={Intent.WARNING} isOpen={isOpen} - onCancel={handleCancelDeliveredEstimate} - onConfirm={handleConfirmEstimateDelivered} + onCancel={handleAlertCancel} + onConfirm={handleAlertConfirm} loading={isLoading} >

diff --git a/client/src/containers/Purchases/Bills/BillForm/BillFloatingActions.js b/client/src/containers/Purchases/Bills/BillForm/BillFloatingActions.js index 93d233caf..ad421fdac 100644 --- a/client/src/containers/Purchases/Bills/BillForm/BillFloatingActions.js +++ b/client/src/containers/Purchases/Bills/BillForm/BillFloatingActions.js @@ -83,7 +83,6 @@ export default function BillFloatingActions() { disabled={isSubmitting} loading={isSubmitting} intent={Intent.PRIMARY} - type="submit" onClick={handleSubmitOpenBtnClick} text={} /> @@ -116,7 +115,6 @@ export default function BillFloatingActions() { - - - - - ); -} - -export default compose( - withItems(({ itemsCurrentPage }) => ({ - itemsCurrentPage, - })), -)(EntriesItemsTable); diff --git a/client/src/containers/Sales/Estimates/EstimateForm/EstimateFloatingActions.js b/client/src/containers/Sales/Estimates/EstimateForm/EstimateFloatingActions.js index 96e9bbd75..0351a910e 100644 --- a/client/src/containers/Sales/Estimates/EstimateForm/EstimateFloatingActions.js +++ b/client/src/containers/Sales/Estimates/EstimateForm/EstimateFloatingActions.js @@ -27,7 +27,8 @@ export default function EstimateFloatingActions() { // Handle submit & deliver button click. const handleSubmitDeliverBtnClick = (event) => { - setSubmitPayload({ redirect: true, deliver: true, }); + setSubmitPayload({ redirect: true, deliver: true }); + submitForm(); }; // Handle submit, deliver & new button click. @@ -77,7 +78,6 @@ export default function EstimateFloatingActions() { disabled={isSubmitting} loading={isSubmitting} intent={Intent.PRIMARY} - type="submit" onClick={handleSubmitDeliverBtnClick} text={} /> @@ -105,12 +105,12 @@ export default function EstimateFloatingActions() { /> + {/* ----------- Save As Draft ----------- */}