feat: optimize customer form performance.

feat: optimize item category form performance.
This commit is contained in:
Ahmed Bouhuolia
2020-11-11 17:18:54 +02:00
parent dcc431b9a9
commit a1e8dbf1c7
16 changed files with 727 additions and 987 deletions

View File

@@ -1,35 +1,26 @@
import React from 'react';
import {
FormGroup,
Intent,
InputGroup,
ControlGroup,
} from '@blueprintjs/core';
import { FormGroup, InputGroup, ControlGroup } from '@blueprintjs/core';
import { FastField, ErrorMessage } from 'formik';
import { FormattedMessage as T } from 'react-intl';
import { ErrorMessage } from 'components';
import { inputIntent } from 'utils';
export default function CustomerFormAfterPrimarySection({
setFieldValue,
getFieldProps,
errors,
values,
touched,
}) {
export default function CustomerFormAfterPrimarySection({}) {
return (
<div class="customer-form__after-primary-section-content">
{/*------------ Customer email -----------*/}
<FormGroup
intent={errors.email && touched.email && Intent.DANGER}
helperText={<ErrorMessage name={'email'} {...{ errors, touched }} />}
className={'form-group--email'}
label={<T id={'customer_email'} />}
inline={true}
>
<InputGroup
intent={errors.email && touched.email && Intent.DANGER}
{...getFieldProps('email')}
/>
</FormGroup>
<FastField name={'email'}>
{({ field, meta: { error, touched } }) => (
<FormGroup
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'email'} />}
className={'form-group--email'}
label={<T id={'customer_email'} />}
inline={true}
>
<InputGroup {...field} />
</FormGroup>
)}
</FastField>
{/*------------ Phone number -----------*/}
<FormGroup
@@ -38,33 +29,41 @@ export default function CustomerFormAfterPrimarySection({
inline={true}
>
<ControlGroup>
<InputGroup
intent={errors.work_phone && touched.work_phone && Intent.DANGER}
{...getFieldProps('work_phone')}
placeholder={'Work'}
/>
<InputGroup
intent={errors.personal_phone && touched.personal_phone && Intent.DANGER}
{...getFieldProps('personal_phone')}
placeholder={'Mobile'}
/>
<FastField name={'work_phone'}>
{({ field, meta: { error, touched } }) => (
<InputGroup
intent={inputIntent({ error, touched })}
placeholder={'Work'}
{...field}
/>
)}
</FastField>
<FastField name={'personal_phone'}>
{({ field, meta: { error, touched } }) => (
<InputGroup
intent={inputIntent({ error, touched })}
placeholder={'Mobile'}
{...field}
/>
)}
</FastField>
</ControlGroup>
</FormGroup>
{/*------------ Customer website -----------*/}
<FormGroup
intent={errors.website && touched.website && Intent.DANGER}
helperText={<ErrorMessage name={'website'} {...{ errors, touched }} />}
className={'form-group--website'}
label={<T id={'website'} />}
inline={true}
>
<InputGroup
intent={errors.website && touched.website && Intent.DANGER}
{...getFieldProps('website')}
/>
</FormGroup>
<FastField name={'website'}>
{({ field, meta: { error, touched } }) => (
<FormGroup
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'website'} />}
className={'form-group--website'}
label={<T id={'website'} />}
inline={true}
>
<InputGroup {...field} />
</FormGroup>
)}
</FastField>
</div>
);
}