From 3f76cb58fe5edbf3edc62de8a8a9a911463e7e6a Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 23 Oct 2025 17:15:17 +0700 Subject: [PATCH] refactor(FE-114): improve alignment and styling of checkbox inputs in RecordingForm --- .../recording/form/RecordingForm.tsx | 48 ++++++++----------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index 120cddb8..45f0cbf5 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -812,19 +812,18 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { {formik.values.feed_data?.map((feed, idx) => ( {type !== 'detail' && ( - -
+ + e: React.ChangeEvent, ) => { if (e.target.checked) { setSelectedFeed([...selectedFeed, idx]); } else { setSelectedFeed( - selectedFeed.filter((i) => i !== idx) + selectedFeed.filter((i) => i !== idx), ); } }} @@ -833,11 +832,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { checkbox: 'checkbox checkbox-sm', }} /> -
)} - { {type !== 'detail' && ( -
+
{ } }} classNames={{ - wrapper: 'flex justify-center', + wrapper: 'flex justify-center items-center h-full', checkbox: 'checkbox checkbox-sm', }} /> @@ -1067,8 +1065,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { {formik.values.body_weight?.map((weight, idx) => ( {type !== 'detail' && ( - -
+ { } }} classNames={{ - wrapper: 'flex justify-center', + wrapper: 'flex justify-center items-center', checkbox: 'checkbox checkbox-sm', }} /> -
)} @@ -1257,7 +1253,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { {type !== 'detail' && ( -
+
{ } }} classNames={{ - wrapper: 'flex justify-center', + wrapper: 'flex justify-center items-center h-full', checkbox: 'checkbox checkbox-sm', }} /> @@ -1312,19 +1308,18 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { {formik.values.vaccination?.map((vaccine, idx) => ( {type !== 'detail' && ( - -
+ + e: React.ChangeEvent, ) => { if (e.target.checked) { setSelectedVaccine([...selectedVaccine, idx]); } else { setSelectedVaccine( - selectedVaccine.filter((i) => i !== idx) + selectedVaccine.filter((i) => i !== idx), ); } }} @@ -1333,11 +1328,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { checkbox: 'checkbox checkbox-sm', }} /> -
)} - { {type !== 'detail' && ( -
+
{ } }} classNames={{ - wrapper: 'flex justify-center', + wrapper: 'flex justify-center items-center h-full', checkbox: 'checkbox checkbox-sm', }} /> @@ -1574,13 +1568,12 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { {formik.values.mortality?.map((mortality, idx) => ( {type !== 'detail' && ( - -
+ + e: React.ChangeEvent, ) => { if (e.target.checked) { setSelectedMortality([ @@ -1589,7 +1582,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { ]); } else { setSelectedMortality( - selectedMortality.filter((i) => i !== idx) + selectedMortality.filter((i) => i !== idx), ); } }} @@ -1598,11 +1591,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { checkbox: 'checkbox checkbox-sm', }} /> -
)} - opt.value === mortality.condition