From 3cf8f4c89b35dd8b0ba52978e5eee5ea94bb7aba Mon Sep 17 00:00:00 2001 From: rstubryan Date: Thu, 23 Oct 2025 16:49:32 +0700 Subject: [PATCH] refactor(FE-114): enhance numeric input handling for chicken weight and count with improved formatting --- .../production/recording/form/RecordingForm.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/pages/production/recording/form/RecordingForm.tsx b/src/components/pages/production/recording/form/RecordingForm.tsx index 2735a7e9..120cddb8 100644 --- a/src/components/pages/production/recording/form/RecordingForm.tsx +++ b/src/components/pages/production/recording/form/RecordingForm.tsx @@ -487,7 +487,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { // Create wrapper handlers that match NumberInput's onChange signature const handleChickenWeightChangeWrapper = useCallback( (idx: number) => (e: React.ChangeEvent) => { - const value = parseFloat(e.target.value) || 0; + const value = parseFloat(e.target.value.replace(/[^\d,.-]/g, '').replace(/,/g, '')) || 0; handleChickenWeightChange(idx, value); }, [handleChickenWeightChange] @@ -495,7 +495,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const handleChickenCountChangeWrapper = useCallback( (idx: number) => (e: React.ChangeEvent) => { - const value = parseFloat(e.target.value) || 0; + const value = parseFloat(e.target.value.replace(/[^\d,.-]/g, '').replace(/,/g, '')) || 0; handleChickenCountChange(idx, value); }, [handleChickenCountChange] @@ -503,7 +503,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { const handleAverageWeightChangeWrapper = useCallback( (idx: number) => (e: React.ChangeEvent) => { - const value = parseFloat(e.target.value) || 0; + const value = parseFloat(e.target.value.replace(/[^\d,.-]/g, '').replace(/,/g, '')) || 0; handleAverageWeightChange(idx, value); }, [handleAverageWeightChange] @@ -1100,8 +1100,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { onBlur={formik.handleBlur} maskType='weight' weightUnit='gram' - decimals={0} + decimals={2} min={0} + thousandSeparator=',' + decimalSeparator='.' isError={ isRepeaterInputError( 'body_weight', @@ -1162,8 +1164,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => { onBlur={formik.handleBlur} maskType='weight' weightUnit='gram' - decimals={0} + decimals={2} min={0} + thousandSeparator=',' + decimalSeparator='.' isError={ isRepeaterInputError( 'body_weight',