mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-114): enhance numeric input handling for chicken weight and count with improved formatting
This commit is contained in:
@@ -487,7 +487,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
// Create wrapper handlers that match NumberInput's onChange signature
|
// Create wrapper handlers that match NumberInput's onChange signature
|
||||||
const handleChickenWeightChangeWrapper = useCallback(
|
const handleChickenWeightChangeWrapper = useCallback(
|
||||||
(idx: number) => (e: React.ChangeEvent<HTMLInputElement>) => {
|
(idx: number) => (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const value = parseFloat(e.target.value) || 0;
|
const value = parseFloat(e.target.value.replace(/[^\d,.-]/g, '').replace(/,/g, '')) || 0;
|
||||||
handleChickenWeightChange(idx, value);
|
handleChickenWeightChange(idx, value);
|
||||||
},
|
},
|
||||||
[handleChickenWeightChange]
|
[handleChickenWeightChange]
|
||||||
@@ -495,7 +495,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
|
|
||||||
const handleChickenCountChangeWrapper = useCallback(
|
const handleChickenCountChangeWrapper = useCallback(
|
||||||
(idx: number) => (e: React.ChangeEvent<HTMLInputElement>) => {
|
(idx: number) => (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const value = parseFloat(e.target.value) || 0;
|
const value = parseFloat(e.target.value.replace(/[^\d,.-]/g, '').replace(/,/g, '')) || 0;
|
||||||
handleChickenCountChange(idx, value);
|
handleChickenCountChange(idx, value);
|
||||||
},
|
},
|
||||||
[handleChickenCountChange]
|
[handleChickenCountChange]
|
||||||
@@ -503,7 +503,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
|
|
||||||
const handleAverageWeightChangeWrapper = useCallback(
|
const handleAverageWeightChangeWrapper = useCallback(
|
||||||
(idx: number) => (e: React.ChangeEvent<HTMLInputElement>) => {
|
(idx: number) => (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const value = parseFloat(e.target.value) || 0;
|
const value = parseFloat(e.target.value.replace(/[^\d,.-]/g, '').replace(/,/g, '')) || 0;
|
||||||
handleAverageWeightChange(idx, value);
|
handleAverageWeightChange(idx, value);
|
||||||
},
|
},
|
||||||
[handleAverageWeightChange]
|
[handleAverageWeightChange]
|
||||||
@@ -1100,8 +1100,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
onBlur={formik.handleBlur}
|
onBlur={formik.handleBlur}
|
||||||
maskType='weight'
|
maskType='weight'
|
||||||
weightUnit='gram'
|
weightUnit='gram'
|
||||||
decimals={0}
|
decimals={2}
|
||||||
min={0}
|
min={0}
|
||||||
|
thousandSeparator=','
|
||||||
|
decimalSeparator='.'
|
||||||
isError={
|
isError={
|
||||||
isRepeaterInputError(
|
isRepeaterInputError(
|
||||||
'body_weight',
|
'body_weight',
|
||||||
@@ -1162,8 +1164,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
onBlur={formik.handleBlur}
|
onBlur={formik.handleBlur}
|
||||||
maskType='weight'
|
maskType='weight'
|
||||||
weightUnit='gram'
|
weightUnit='gram'
|
||||||
decimals={0}
|
decimals={2}
|
||||||
min={0}
|
min={0}
|
||||||
|
thousandSeparator=','
|
||||||
|
decimalSeparator='.'
|
||||||
isError={
|
isError={
|
||||||
isRepeaterInputError(
|
isRepeaterInputError(
|
||||||
'body_weight',
|
'body_weight',
|
||||||
|
|||||||
Reference in New Issue
Block a user