From a1e8dbf1c7cbe801cce9b751b7230c515404de7b Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Wed, 11 Nov 2020 17:18:54 +0200 Subject: [PATCH] feat: optimize customer form performance. feat: optimize item category form performance. --- client/src/containers/Customers/Customer.js | 2 +- .../Customers/CustomerAddressTabs.js | 521 +++++++----------- .../Customers/CustomerFinancialPanel.js | 168 +++--- .../src/containers/Customers/CustomerForm.js | 123 ++--- .../CustomerFormAfterPrimarySection.js | 97 ++-- .../Customers/CustomerFormPrimarySection.js | 182 +++--- .../containers/Customers/CustomerNotePanel.js | 32 +- .../Customers/CustomerTypeRadioField.js | 42 +- .../src/containers/Customers/CustomersTabs.js | 31 +- .../ItemCategoryDialog/ItemCategoryForm.js | 216 ++++++++ .../ItemCategoryFormDialogContent.js | 268 +-------- client/src/containers/Items/ItemForm.js | 3 +- client/src/containers/Items/ItemFormBody.js | 1 - .../Items/ItemFormFloatingActions.js | 10 +- .../Items/ItemFormInventorySection.js | 4 +- .../Items/ItemFormPrimarySection.js | 14 +- 16 files changed, 727 insertions(+), 987 deletions(-) create mode 100644 client/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryForm.js diff --git a/client/src/containers/Customers/Customer.js b/client/src/containers/Customers/Customer.js index edf1552f2..2bc2b9a5e 100644 --- a/client/src/containers/Customers/Customer.js +++ b/client/src/containers/Customers/Customer.js @@ -42,7 +42,7 @@ function Customer({ const handleFormSubmit = useCallback( (payload) => { - payload.redirect && history.push('/customers'); + }, [history], ); diff --git a/client/src/containers/Customers/CustomerAddressTabs.js b/client/src/containers/Customers/CustomerAddressTabs.js index bc6e067b4..63f3824ed 100644 --- a/client/src/containers/Customers/CustomerAddressTabs.js +++ b/client/src/containers/Customers/CustomerAddressTabs.js @@ -1,16 +1,11 @@ import React from 'react'; -import { FormGroup, Intent, InputGroup, TextArea } from '@blueprintjs/core'; +import { FormGroup, InputGroup, TextArea } from '@blueprintjs/core'; import { Row, Col } from 'components'; import { FormattedMessage as T } from 'react-intl'; +import { FastField, ErrorMessage } from 'formik'; +import { inputIntent } from 'utils'; -import ErrorMessage from 'components/ErrorMessage'; - -const CustomerBillingAddress = ({ - errors, - touched, - setFieldValue, - getFieldProps, -}) => { +const CustomerBillingAddress = ({}) => { return (
@@ -19,172 +14,105 @@ const CustomerBillingAddress = ({ {/*------------ Billing Address country -----------*/} - - } - label={} - > - - + + {({ field, field: { value }, meta: { error, touched } }) => ( + } + label={} + > + + + )} + + {/*------------ Billing Address 1 -----------*/} - } - className={'form-group--address_line_1'} - intent={ - errors.billing_address_1 && - touched.billing_address_1 && - Intent.DANGER - } - inline={true} - helperText={ - - } - > -