mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +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);
|
formik.setFieldValue('area_id', (area as OptionType)?.value || 0);
|
||||||
|
|
||||||
// Reset area dependent fields
|
// 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);
|
formik.setFieldValue('location_id', 0);
|
||||||
setLocationSelectInputValue('');
|
setLocationSelectInputValue('');
|
||||||
|
|
||||||
@@ -590,7 +592,7 @@ const PurchaseRequestForm = ({
|
|||||||
? 'Pilih Area terlebih dahulu'
|
? 'Pilih Area terlebih dahulu'
|
||||||
: 'Pilih Lokasi...'
|
: 'Pilih Lokasi...'
|
||||||
}
|
}
|
||||||
value={formik.values.location}
|
value={formik.values.area_id ? formik.values.location : null}
|
||||||
onChange={locationChangeHandler}
|
onChange={locationChangeHandler}
|
||||||
options={locationOptions}
|
options={locationOptions}
|
||||||
onInputChange={setLocationSelectInputValue}
|
onInputChange={setLocationSelectInputValue}
|
||||||
@@ -601,6 +603,7 @@ const PurchaseRequestForm = ({
|
|||||||
errorMessage={formik.errors.location_id as string}
|
errorMessage={formik.errors.location_id as string}
|
||||||
isDisabled={type === 'detail' || !formik.values.area_id}
|
isDisabled={type === 'detail' || !formik.values.area_id}
|
||||||
isClearable={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'}>
|
<div className={type === 'detail' ? 'col-span-1' : 'col-span-2'}>
|
||||||
|
|||||||
Reference in New Issue
Block a user