diff --git a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema.ts b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema.ts index bde85b50..d7a0ae0a 100644 --- a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema.ts +++ b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.schema.ts @@ -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() diff --git a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx index e614c9aa..1bb1692d 100644 --- a/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx +++ b/src/components/pages/inventory/adjustment/form/InventoryAdjustmentForm.tsx @@ -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.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 */} - { - 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 */} + {/* Number Input Stock */} + { + 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 */}