mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-208,212): update PurchaseRequestForm to reset location fields on area change, improve handling of location value and dependencies
This commit is contained in:
@@ -391,7 +391,9 @@ const PurchaseRequestForm = ({
|
||||
formik.setFieldValue('area_id', (area as OptionType)?.value || 0);
|
||||
|
||||
// Reset area dependent fields
|
||||
formik.setFieldValue('location', null);
|
||||
formik.setFieldTouched('location', false);
|
||||
formik.setFieldValue('location', undefined);
|
||||
formik.setFieldTouched('location_id', false);
|
||||
formik.setFieldValue('location_id', 0);
|
||||
setLocationSelectInputValue('');
|
||||
|
||||
@@ -590,7 +592,7 @@ const PurchaseRequestForm = ({
|
||||
? 'Pilih Area terlebih dahulu'
|
||||
: 'Pilih Lokasi...'
|
||||
}
|
||||
value={formik.values.location}
|
||||
value={formik.values.area_id ? formik.values.location : null}
|
||||
onChange={locationChangeHandler}
|
||||
options={locationOptions}
|
||||
onInputChange={setLocationSelectInputValue}
|
||||
@@ -601,6 +603,7 @@ const PurchaseRequestForm = ({
|
||||
errorMessage={formik.errors.location_id as string}
|
||||
isDisabled={type === 'detail' || !formik.values.area_id}
|
||||
isClearable={type !== 'detail' && !!formik.values.area_id}
|
||||
key={`location-${formik.values.area_id}`}
|
||||
/>
|
||||
|
||||
<div className={type === 'detail' ? 'col-span-1' : 'col-span-2'}>
|
||||
|
||||
Reference in New Issue
Block a user