From 4149c51a7bd2b677e0cc3cce86a5dbe88d73945c Mon Sep 17 00:00:00 2001 From: rstubryan Date: Mon, 3 Nov 2025 14:29:24 +0700 Subject: [PATCH] refactor(FE-208,212): update PurchaseRequestForm validation for area and location fields, enhance error handling and conditional checks --- .../pages/purchase/form/PurchaseRequestForm.schema.ts | 10 ++++++++-- .../pages/purchase/form/PurchaseRequestForm.tsx | 5 ++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/components/pages/purchase/form/PurchaseRequestForm.schema.ts b/src/components/pages/purchase/form/PurchaseRequestForm.schema.ts index ebd0792d..8a84b3f4 100644 --- a/src/components/pages/purchase/form/PurchaseRequestForm.schema.ts +++ b/src/components/pages/purchase/form/PurchaseRequestForm.schema.ts @@ -106,7 +106,10 @@ export const PurchaseRequestFormSchema: Yup.ObjectSchema 0); + }) .typeError('Area wajib diisi!'), location: Yup.object({ value: Yup.number().min(1).required(), @@ -114,7 +117,10 @@ export const PurchaseRequestFormSchema: Yup.ObjectSchema 0); + }) .typeError('Lokasi wajib diisi!'), credit_term: Yup.number() .required('Termin kredit wajib diisi!') diff --git a/src/components/pages/purchase/form/PurchaseRequestForm.tsx b/src/components/pages/purchase/form/PurchaseRequestForm.tsx index 0f7b7225..dce21146 100644 --- a/src/components/pages/purchase/form/PurchaseRequestForm.tsx +++ b/src/components/pages/purchase/form/PurchaseRequestForm.tsx @@ -543,7 +543,7 @@ const PurchaseRequestForm = ({ onInputChange={setAreaSelectInputValue} isLoading={isLoadingAreas} isError={ - formik.touched.area_id && Boolean(formik.errors.area_id) + formik.touched.area && Boolean(formik.errors.area_id) } errorMessage={formik.errors.area_id as string} isDisabled={type === 'detail'} @@ -564,8 +564,7 @@ const PurchaseRequestForm = ({ onInputChange={setLocationSelectInputValue} isLoading={isLoadingLocations} isError={ - formik.touched.location_id && - Boolean(formik.errors.location_id) + formik.touched.location && Boolean(formik.errors.location_id) } errorMessage={formik.errors.location_id as string} isDisabled={type === 'detail' || !formik.values.area_id}