From af492310e88aa136d57dfb1dab9bc1b32a179253 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Tue, 14 Sep 2021 16:50:22 +0200 Subject: [PATCH] BIG-81: handle error message. --- client/src/common/errors.js | 3 ++- .../Sales/Estimates/EstimateForm/EstimateForm.js | 7 +++++++ .../Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.js | 1 + client/src/containers/Sales/Invoices/InvoiceForm/utils.js | 3 +-- client/src/lang/en/index.json | 4 +++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/client/src/common/errors.js b/client/src/common/errors.js index 5b50b487a..e69a3f199 100644 --- a/client/src/common/errors.js +++ b/client/src/common/errors.js @@ -1,6 +1,7 @@ export const ERROR = { // Sales Estimates ESTIMATE_NUMBER_IS_NOT_UNQIUE: 'ESTIMATE.NUMBER.IS.NOT.UNQIUE', + SALE_ESTIMATE_NO_IS_REQUIRED: 'SALE_ESTIMATE_NO_IS_REQUIRED', // Sales Invoices SALE_INVOICE_NUMBER_IS_EXISTS: 'SALE.INVOICE.NUMBER.IS.EXISTS', @@ -13,5 +14,5 @@ export const ERROR = { // Bills BILL_NUMBER_EXISTS: 'BILL.NUMBER.EXISTS', - SALE_INVOICE_NO_IS_REQUIRED: 'SALE_INVOICE_NO_IS_REQUIRED' + SALE_INVOICE_NO_IS_REQUIRED: 'SALE_INVOICE_NO_IS_REQUIRED', }; diff --git a/client/src/containers/Sales/Estimates/EstimateForm/EstimateForm.js b/client/src/containers/Sales/Estimates/EstimateForm/EstimateForm.js index 4bb8f542b..eb9b9578c 100644 --- a/client/src/containers/Sales/Estimates/EstimateForm/EstimateForm.js +++ b/client/src/containers/Sales/Estimates/EstimateForm/EstimateForm.js @@ -78,6 +78,13 @@ function EstimateForm({ estimate_number: intl.get('estimate_number_is_not_unqiue'), }); } + if ( + errors.some((error) => error.type === ERROR.SALE_ESTIMATE_NO_IS_REQUIRED) + ) { + setErrors({ + estimate_number: intl.get('estimate.field.error.estimate_number'), + }); + } }; // Handles form submit. diff --git a/client/src/containers/Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.js b/client/src/containers/Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.js index 96594a06c..1775d8d78 100644 --- a/client/src/containers/Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.js +++ b/client/src/containers/Sales/Invoices/InvoiceForm/InvoiceFormHeaderFields.js @@ -153,6 +153,7 @@ function InvoiceFormHeaderFields({ {({ form, field, meta: { error, touched } }) => ( } + labelInfo={} inline={true} className={classNames('form-group--invoice-no', CLASSES.FILL)} intent={inputIntent({ error, touched })} diff --git a/client/src/containers/Sales/Invoices/InvoiceForm/utils.js b/client/src/containers/Sales/Invoices/InvoiceForm/utils.js index 96f658788..6ac7682bd 100644 --- a/client/src/containers/Sales/Invoices/InvoiceForm/utils.js +++ b/client/src/containers/Sales/Invoices/InvoiceForm/utils.js @@ -93,8 +93,7 @@ export const transformErrors = (errors, { setErrors }) => { errors.some((error) => error.type === ERROR.SALE_INVOICE_NO_IS_REQUIRED) ) { setErrors({ - invoice_no: - 'Invoice number is required, use auto-increment mode or enter manually.', + invoice_no: intl.get('invoice.field.error.invoice_no'), }); } }; diff --git a/client/src/lang/en/index.json b/client/src/lang/en/index.json index fc5514fe8..4ed207dc5 100644 --- a/client/src/lang/en/index.json +++ b/client/src/lang/en/index.json @@ -1323,5 +1323,7 @@ "payment_receive.auto_increment.manually": "Yor payment numbers are set on manual mode. Are you sure chaning this settings?", "auto_increment.field.manually": "I will enter them manually each time", "auto_increment.field.manual_this_transaction": "Manual entering for this transaction.", - "auto_increment.field.auto": "Auto-incrementing number." + "auto_increment.field.auto": "Auto-incrementing number.", + "estimate.field.error.estimate_number":"Estimate number is required, use auto-increment mode or enter manually.", + "invoice.field.error.invoice_no":"Invoice number is required, use auto-increment mode or enter manually" } \ No newline at end of file