mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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()
|
||||
.oneOf(['increase', 'decrease'], 'Tipe transaksi tidak valid')
|
||||
.nullable()
|
||||
.required('Tipe transaksi wajib diisi'),
|
||||
|
||||
quantity: Yup.number()
|
||||
|
||||
@@ -77,7 +77,7 @@ const InventoryAdjustmentForm = ({
|
||||
product: undefined,
|
||||
warehouse: undefined,
|
||||
quantity: initialValues?.quantity ?? 0,
|
||||
transaction_type: initialValues?.transaction_type ?? 'increase',
|
||||
transaction_type: undefined,
|
||||
note: initialValues?.note ?? '',
|
||||
};
|
||||
}, [initialValues]);
|
||||
@@ -153,13 +153,14 @@ const InventoryAdjustmentForm = ({
|
||||
formik.setFieldValue('product_category_id', (val as OptionType)?.value);
|
||||
|
||||
formik.setFieldValue('product_category', val);
|
||||
|
||||
setSelectedProductCategories((val as OptionType)?.value as string);
|
||||
const disabled = (val as OptionType)?.value == null;
|
||||
setDisabledProduct(disabled);
|
||||
if (disabled) {
|
||||
formik.setFieldValue('product_id', 0);
|
||||
formik.setFieldValue('product', null);
|
||||
}
|
||||
formik.setFieldTouched('product', false);
|
||||
formik.setFieldTouched('product_id', false);
|
||||
};
|
||||
|
||||
const productChangeHandler = (val: OptionType | OptionType[] | null) => {
|
||||
@@ -340,30 +341,6 @@ const InventoryAdjustmentForm = ({
|
||||
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 */}
|
||||
<RadioInput
|
||||
name='transaction_type'
|
||||
@@ -387,10 +364,39 @@ const InventoryAdjustmentForm = ({
|
||||
errorMessage={formik.errors.transaction_type as string}
|
||||
variant='radio-primary'
|
||||
required
|
||||
bottomLabel='Pilih salah satu tipe transaksi'
|
||||
bottomLabel={formik.values.transaction_type == undefined ? 'Pilih salah satu tipe transaksi' : undefined}
|
||||
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 */}
|
||||
<TextArea
|
||||
required
|
||||
|
||||
Reference in New Issue
Block a user