diff --git a/packages/webapp/src/components/Forms/FMoneyInputGroup.tsx b/packages/webapp/src/components/Forms/FMoneyInputGroup.tsx index c0297e52d..3a381115a 100644 --- a/packages/webapp/src/components/Forms/FMoneyInputGroup.tsx +++ b/packages/webapp/src/components/Forms/FMoneyInputGroup.tsx @@ -1,7 +1,7 @@ // @ts-nocheck import React from 'react'; import { Intent } from '@blueprintjs/core'; -import { Field, getIn } from 'formik'; +import { Field, FastField, getIn } from 'formik'; import { CurrencyInput } from './MoneyInputGroup'; const fieldToMoneyInputGroup = ({ @@ -32,6 +32,7 @@ function FieldToMoneyInputGroup({ ...props }) { return ; } -export function FMoneyInputGroup({ ...props }) { - return ; +export function FMoneyInputGroup({ fastField, ...props }) { + const FieldComponent = fastField ? FastField : Field; + return ; } diff --git a/packages/webapp/src/containers/Dialogs/InventoryAdjustmentFormDialog/IncrementAdjustmentFields.tsx b/packages/webapp/src/containers/Dialogs/InventoryAdjustmentFormDialog/IncrementAdjustmentFields.tsx index 1373f2f7b..d78adc62b 100644 --- a/packages/webapp/src/containers/Dialogs/InventoryAdjustmentFormDialog/IncrementAdjustmentFields.tsx +++ b/packages/webapp/src/containers/Dialogs/InventoryAdjustmentFormDialog/IncrementAdjustmentFields.tsx @@ -1,35 +1,38 @@ // @ts-nocheck import React from 'react'; -import { Field, FastField, ErrorMessage } from 'formik'; -import { FormGroup, InputGroup } from '@blueprintjs/core'; +import { useFormikContext } from 'formik'; import { useAutofocus } from '@/hooks'; -import { Row, Col, MoneyInputGroup, FormattedMessage as T } from '@/components'; -import { inputIntent, toSafeNumber } from '@/utils'; +import { + Row, + Col, + FMoneyInputGroup, + FormattedMessage as T, + FFormGroup, + FInputGroup, +} from '@/components'; +import { toSafeNumber } from '@/utils'; import { decrementQuantity, incrementQuantity } from './utils'; export default function IncrementAdjustmentFields() { const incrementFieldRef = useAutofocus(); + const { values, setFieldValue } = useFormikContext(); return ( {/*------------ Quantity on hand -----------*/} - - {({ field, meta: { error, touched } }) => ( - } - intent={inputIntent({ error, touched })} - helperText={} - > - - - )} - + } + fastField + > + + {/*------------ Sign -----------*/} @@ -39,65 +42,36 @@ export default function IncrementAdjustmentFields() { {/*------------ Increment -----------*/} - - {({ - form: { values, setFieldValue }, - field, - meta: { error, touched }, - }) => ( - } - intent={inputIntent({ error, touched })} - helperText={} - fill={true} - > - (incrementFieldRef.current = ref)} - onChange={(value) => { - setFieldValue('quantity', value); - }} - onBlurValue={(value) => { - setFieldValue( - 'new_quantity', - incrementQuantity( - toSafeNumber(value), - toSafeNumber(values.quantity_on_hand), - ), - ); - }} - intent={inputIntent({ error, touched })} - /> - - )} - + } + fill + fastField + > + (incrementFieldRef.current = ref)} + onBlurValue={(value) => { + setFieldValue( + 'new_quantity', + incrementQuantity( + toSafeNumber(value), + toSafeNumber(values.quantity_on_hand), + ), + ); + }} + fastField + /> + {/*------------ Cost -----------*/} - - {({ - form: { setFieldValue }, - field: { value }, - meta: { error, touched }, - }) => ( - } - intent={inputIntent({ error, touched })} - helperText={} - > - { - setFieldValue('cost', value); - }} - intent={inputIntent({ error, touched })} - /> - - )} - + } fastField> + + {/*------------ Sign -----------*/} @@ -107,38 +81,27 @@ export default function IncrementAdjustmentFields() { {/*------------ New quantity -----------*/} - - {({ - form: { values, setFieldValue }, - field, - meta: { error, touched }, - }) => ( - } - intent={inputIntent({ error, touched })} - helperText={} - > - { - setFieldValue('new_quantity', value); - }} - onBlurValue={(value) => { - setFieldValue( - 'quantity', - decrementQuantity( - toSafeNumber(value), - toSafeNumber(values.quantity_on_hand), - ), - ); - }} - intent={inputIntent({ error, touched })} - /> - - )} - + } + fastField + > + { + setFieldValue( + 'quantity', + decrementQuantity( + toSafeNumber(value), + toSafeNumber(values.quantity_on_hand), + ), + ); + }} + fastField + /> + ); diff --git a/packages/webapp/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryFormFields.tsx b/packages/webapp/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryFormFields.tsx index 87825a8c2..5db382cdf 100644 --- a/packages/webapp/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryFormFields.tsx +++ b/packages/webapp/src/containers/Dialogs/ItemCategoryDialog/ItemCategoryFormFields.tsx @@ -1,11 +1,15 @@ // @ts-nocheck import React from 'react'; -import { Classes, FormGroup, InputGroup, TextArea } from '@blueprintjs/core'; -import { FormattedMessage as T, FieldRequiredHint } from '@/components'; -import { ErrorMessage, FastField } from 'formik'; +import { Classes } from '@blueprintjs/core'; +import { + FormattedMessage as T, + FieldRequiredHint, + FFormGroup, + FInputGroup, + FTextArea, +} from '@/components'; import { useAutofocus } from '@/hooks'; -import { inputIntent } from '@/utils'; /** * Item category form fields. @@ -16,45 +20,35 @@ export default function ItemCategoryFormFields() { return (
{/* ----------- Category name ----------- */} - - {({ field, field: { value }, meta: { error, touched } }) => ( - } - labelInfo={} - className={'form-group--category-name'} - intent={inputIntent({ error, touched })} - helperText={} - inline={true} - > - (categoryNameFieldRef.current = ref)} - intent={inputIntent({ error, touched })} - {...field} - /> - - )} - + } + labelInfo={} + inline + fastField + > + (categoryNameFieldRef.current = ref)} + fastField + /> + {/* ----------- Description ----------- */} - - {({ field, field: { value }, meta: { error, touched } }) => ( - } - className={'form-group--description'} - intent={inputIntent({ error, touched })} - helperText={} - inline={true} - > -