mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
fix(FE-54) fix form input state inventory adjustment
This commit is contained in:
@@ -27,6 +27,7 @@ export const InventoryAdjustmentFormSchema = Yup.object({
|
|||||||
|
|
||||||
transaction_type: Yup.string()
|
transaction_type: Yup.string()
|
||||||
.oneOf(['increase', 'decrease'], 'Tipe transaksi tidak valid')
|
.oneOf(['increase', 'decrease'], 'Tipe transaksi tidak valid')
|
||||||
|
.nullable()
|
||||||
.required('Tipe transaksi wajib diisi'),
|
.required('Tipe transaksi wajib diisi'),
|
||||||
|
|
||||||
quantity: Yup.number()
|
quantity: Yup.number()
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const InventoryAdjustmentForm = ({
|
|||||||
product: undefined,
|
product: undefined,
|
||||||
warehouse: undefined,
|
warehouse: undefined,
|
||||||
quantity: initialValues?.quantity ?? 0,
|
quantity: initialValues?.quantity ?? 0,
|
||||||
transaction_type: initialValues?.transaction_type ?? 'increase',
|
transaction_type: undefined,
|
||||||
note: initialValues?.note ?? '',
|
note: initialValues?.note ?? '',
|
||||||
};
|
};
|
||||||
}, [initialValues]);
|
}, [initialValues]);
|
||||||
@@ -153,13 +153,14 @@ const InventoryAdjustmentForm = ({
|
|||||||
formik.setFieldValue('product_category_id', (val as OptionType)?.value);
|
formik.setFieldValue('product_category_id', (val as OptionType)?.value);
|
||||||
|
|
||||||
formik.setFieldValue('product_category', val);
|
formik.setFieldValue('product_category', val);
|
||||||
|
|
||||||
setSelectedProductCategories((val as OptionType)?.value as string);
|
setSelectedProductCategories((val as OptionType)?.value as string);
|
||||||
const disabled = (val as OptionType)?.value == null;
|
const disabled = (val as OptionType)?.value == null;
|
||||||
setDisabledProduct(disabled);
|
setDisabledProduct(disabled);
|
||||||
if (disabled) {
|
formik.setFieldValue('product_id', 0);
|
||||||
formik.setFieldValue('product_id', 0);
|
formik.setFieldValue('product', null);
|
||||||
formik.setFieldValue('product', null);
|
formik.setFieldTouched('product', false);
|
||||||
}
|
formik.setFieldTouched('product_id', false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const productChangeHandler = (val: OptionType | OptionType[] | null) => {
|
const productChangeHandler = (val: OptionType | OptionType[] | null) => {
|
||||||
@@ -340,30 +341,6 @@ const InventoryAdjustmentForm = ({
|
|||||||
isClearable
|
isClearable
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Number Input Stock */}
|
|
||||||
<TextInput
|
|
||||||
required
|
|
||||||
label={quantityLabel}
|
|
||||||
name='quantity'
|
|
||||||
type='text'
|
|
||||||
value={formatNumber(String(formik.values.quantity))}
|
|
||||||
onChange={(e) => {
|
|
||||||
const rawValue = e.target.value.replace(/,/g, '');
|
|
||||||
const numericValue = parseFloat(rawValue);
|
|
||||||
if (!isNaN(numericValue)) {
|
|
||||||
formik.setFieldValue('quantity', numericValue);
|
|
||||||
} else {
|
|
||||||
formik.setFieldValue('quantity', 0);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
onBlur={formik.handleBlur}
|
|
||||||
isError={
|
|
||||||
formik.touched.quantity && Boolean(formik.errors.quantity)
|
|
||||||
}
|
|
||||||
errorMessage={formik.errors.quantity as string}
|
|
||||||
readOnly={type === 'detail'}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Radio Button Flag Stock */}
|
{/* Radio Button Flag Stock */}
|
||||||
<RadioInput
|
<RadioInput
|
||||||
name='transaction_type'
|
name='transaction_type'
|
||||||
@@ -387,10 +364,39 @@ const InventoryAdjustmentForm = ({
|
|||||||
errorMessage={formik.errors.transaction_type as string}
|
errorMessage={formik.errors.transaction_type as string}
|
||||||
variant='radio-primary'
|
variant='radio-primary'
|
||||||
required
|
required
|
||||||
bottomLabel='Pilih salah satu tipe transaksi'
|
bottomLabel={formik.values.transaction_type == undefined ? 'Pilih salah satu tipe transaksi' : undefined}
|
||||||
disabled={type === 'detail'}
|
disabled={type === 'detail'}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Number Input Stock */}
|
||||||
|
<TextInput
|
||||||
|
className={{
|
||||||
|
wrapper: `${formik.values.transaction_type != undefined ? '' : 'hidden'}`,
|
||||||
|
}}
|
||||||
|
required
|
||||||
|
label={quantityLabel}
|
||||||
|
name='quantity'
|
||||||
|
type='text'
|
||||||
|
value={formatNumber(String(formik.values.quantity))}
|
||||||
|
onChange={(e) => {
|
||||||
|
const rawValue = e.target.value.replace(/,/g, '');
|
||||||
|
const numericValue = parseFloat(rawValue);
|
||||||
|
if (!isNaN(numericValue)) {
|
||||||
|
formik.setFieldValue('quantity', numericValue);
|
||||||
|
} else {
|
||||||
|
formik.setFieldValue('quantity', 0);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onBlur={formik.handleBlur}
|
||||||
|
isError={
|
||||||
|
formik.touched.quantity && Boolean(formik.errors.quantity)
|
||||||
|
}
|
||||||
|
errorMessage={formik.errors.quantity as string}
|
||||||
|
readOnly={type === 'detail'}
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{/* Text Area Input Reason */}
|
{/* Text Area Input Reason */}
|
||||||
<TextArea
|
<TextArea
|
||||||
required
|
required
|
||||||
|
|||||||
Reference in New Issue
Block a user