mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 07:15:44 +00:00
refactor(FE-114): ensure fields are marked as touched on change for better validation handling
This commit is contained in:
@@ -568,7 +568,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
required
|
required
|
||||||
label='Lokasi'
|
label='Lokasi'
|
||||||
value={formik.values.location ?? undefined}
|
value={formik.values.location ?? undefined}
|
||||||
onChange={locationChangeHandler}
|
onChange={(val) => {
|
||||||
|
formik.setFieldTouched('location', true);
|
||||||
|
formik.setFieldTouched('location_id', true);
|
||||||
|
locationChangeHandler(val);
|
||||||
|
}}
|
||||||
options={locationOptions}
|
options={locationOptions}
|
||||||
onInputChange={setLocationSelectInputValue}
|
onInputChange={setLocationSelectInputValue}
|
||||||
isLoading={isLoadingLocations}
|
isLoading={isLoadingLocations}
|
||||||
@@ -613,7 +617,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
required
|
required
|
||||||
label='Flock'
|
label='Flock'
|
||||||
value={formik.values.flock ?? undefined}
|
value={formik.values.flock ?? undefined}
|
||||||
onChange={flockChangeHandler}
|
onChange={(val) => {
|
||||||
|
formik.setFieldTouched('flock', true);
|
||||||
|
formik.setFieldTouched('flock_id', true);
|
||||||
|
flockChangeHandler(val);
|
||||||
|
}}
|
||||||
options={flockOptions}
|
options={flockOptions}
|
||||||
onInputChange={setFlockSelectInputValue}
|
onInputChange={setFlockSelectInputValue}
|
||||||
isLoading={isLoadingFlocks}
|
isLoading={isLoadingFlocks}
|
||||||
@@ -635,7 +643,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
required
|
required
|
||||||
label='Kandang'
|
label='Kandang'
|
||||||
value={formik.values.coop ?? undefined}
|
value={formik.values.coop ?? undefined}
|
||||||
onChange={coopChangeHandler}
|
onChange={(val) => {
|
||||||
|
formik.setFieldTouched('coop', true);
|
||||||
|
formik.setFieldTouched('coop_id', true);
|
||||||
|
coopChangeHandler(val);
|
||||||
|
}}
|
||||||
options={coopOptions}
|
options={coopOptions}
|
||||||
isError={
|
isError={
|
||||||
formik.touched.coop_id && Boolean(formik.errors.coop_id)
|
formik.touched.coop_id && Boolean(formik.errors.coop_id)
|
||||||
@@ -737,6 +749,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
) ?? '')
|
) ?? '')
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
|
formik.setFieldTouched(
|
||||||
|
`feed_data.${idx}.feed`,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
formik.setFieldTouched(
|
||||||
|
`feed_data.${idx}.feed_id`,
|
||||||
|
true
|
||||||
|
);
|
||||||
formik.setFieldValue(
|
formik.setFieldValue(
|
||||||
`feed_data.${idx}.feed`,
|
`feed_data.${idx}.feed`,
|
||||||
val
|
val
|
||||||
@@ -1193,6 +1213,14 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
productWarehouseId as number
|
productWarehouseId as number
|
||||||
) ?? '')
|
) ?? '')
|
||||||
: '';
|
: '';
|
||||||
|
formik.setFieldTouched(
|
||||||
|
`vaccination.${idx}.vaccine`,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
formik.setFieldTouched(
|
||||||
|
`vaccination.${idx}.vaccine_id`,
|
||||||
|
true
|
||||||
|
);
|
||||||
formik.setFieldValue(
|
formik.setFieldValue(
|
||||||
`vaccination.${idx}.vaccine`,
|
`vaccination.${idx}.vaccine`,
|
||||||
val
|
val
|
||||||
@@ -1413,6 +1441,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
(opt) => opt.value === mortality.condition
|
(opt) => opt.value === mortality.condition
|
||||||
)}
|
)}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
|
formik.setFieldTouched(
|
||||||
|
`mortality.${idx}.condition`,
|
||||||
|
true
|
||||||
|
);
|
||||||
formik.setFieldValue(
|
formik.setFieldValue(
|
||||||
`mortality.${idx}.condition`,
|
`mortality.${idx}.condition`,
|
||||||
(val as OptionType)?.value
|
(val as OptionType)?.value
|
||||||
|
|||||||
Reference in New Issue
Block a user