refactor(FE-114): enforce required usage amount in RecordingForm validation

This commit is contained in:
rstubryan
2025-10-24 10:00:35 +07:00
parent 714072aea1
commit ca5b236565
2 changed files with 2 additions and 1 deletions
@@ -48,7 +48,7 @@ export const RecordingFormSchema = Yup.object({
.min(1, 'Produk wajib diisi!') .min(1, 'Produk wajib diisi!')
.typeError('Produk harus berupa angka!'), .typeError('Produk harus berupa angka!'),
usage_amount: Yup.number() usage_amount: Yup.number()
.optional() .required('Jumlah penggunaan wajib diisi!')
.min(0, 'Jumlah penggunaan tidak boleh negatif!') .min(0, 'Jumlah penggunaan tidak boleh negatif!')
.typeError('Jumlah penggunaan harus berupa angka!'), .typeError('Jumlah penggunaan harus berupa angka!'),
notes: Yup.string().optional(), notes: Yup.string().optional(),
@@ -903,6 +903,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
</td> </td>
<td> <td>
<NumberInput <NumberInput
required
name={`stocks.${idx}.usage_amount`} name={`stocks.${idx}.usage_amount`}
value={stock.usage_amount || 0} value={stock.usage_amount || 0}
onChange={formik.handleChange} onChange={formik.handleChange}