{
-
- const [selectedAccounts, setSelectedAccounts] = useState({});
const [payload, setPayload] = useState({});
const history = useHistory();
@@ -232,19 +226,11 @@ const ItemForm = ({
}
};
-
- const onItemAccountSelect = useCallback(
- (filedName) => {
- return (account) => {
- setSelectedAccounts({
- ...selectedAccounts,
- [filedName]: account,
- });
- setFieldValue(filedName, account.id);
- };
- },
- [setFieldValue, selectedAccounts]
- );
+ const onItemAccountSelect = useCallback((filedName) => {
+ return (account) => {
+ setFieldValue(filedName, account.id);
+ };
+ }, [setFieldValue]);
const categoryItem = useCallback(
(item, { handleClick }) => (
@@ -253,16 +239,6 @@ const ItemForm = ({
[]
);
-
- const getSelectedAccountLabel = useCallback(
- (fieldName, defaultLabel) => {
- return typeof selectedAccounts[fieldName] !== 'undefined'
- ? selectedAccounts[fieldName].name
- : defaultLabel;
- },
- [selectedAccounts]
- );
-
const requiredSpan = useMemo(() => *, []);
const infoIcon = useMemo(() => , []);
@@ -307,6 +283,8 @@ const ItemForm = ({
+
+ {/* Item type */}
}
@@ -324,7 +302,8 @@ const ItemForm = ({
{...getFieldProps('type')}
/>
-
+
+ {/* Item name */}
}
labelInfo={requiredSpan}
@@ -342,14 +321,13 @@ const ItemForm = ({
/>
+ {/* SKU */}
}
labelInfo={infoIcon}
className={'form-group--item-sku'}
intent={errors.sku && touched.sku && Intent.DANGER}
- helperText={
-
- }
+ helperText={}
inline={true}
>
+ {/* Item category */}
}
labelInfo={infoIcon}
@@ -375,24 +354,22 @@ const ItemForm = ({
Classes.FILL
)}
>
-
-
+ selectedItem={values.category_id}
+ selectedItemProp={'id'}
+
+ defaultText={}
+ labelProp={'name'}
+ />
+
+
+ {/* Active checkbox */}
}
className={'form-group--item-selling-price'}
- intent={
- errors.selling_price && touched.selling_price && Intent.DANGER
- }
+ intent={errors.selling_price && touched.selling_price && Intent.DANGER}
helperText={
}
@@ -447,7 +422,8 @@ const ItemForm = ({
}}
/>
-
+
+ {/* Selling account */}
}
labelInfo={infoIcon}
@@ -466,30 +442,26 @@ const ItemForm = ({
Classes.FILL
)}
>
-
+
+ selectedItem={values.sell_account_id}
+ selectedItemProp={'id'}
+
+ defaultText={}
+ labelProp={'name'}
+ />
-
-
-
+
+ {/* Cost price */}
}
className={'form-group--item-cost-price'}
@@ -529,23 +501,18 @@ const ItemForm = ({
Classes.FILL
)}
>
-
+
+ defaultText={}
+ labelProp={'name'}
+ selectedItem={values.cost_account_id}
+ selectedItemProp={'id'}
+ />
@@ -564,35 +531,24 @@ const ItemForm = ({
touched.inventory_account_id &&
Intent.DANGER
}
- helperText={
-
- }
+ helperText={}
className={classNames(
'form-group--item-inventory_account',
'form-group--select-list',
Classes.FILL
)}
>
-
+
+ defaultText={}
+ labelProp={'name'}
+ selectedItem={values.inventory_account_id}
+ selectedItemProp={'id'} />