mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-24 15:25:46 +00:00
refactor(FE-114): simplify input handling in MovementForm and RecordingForm by removing unnecessary value normalization
This commit is contained in:
@@ -427,9 +427,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
|
||||
const handleDeliveryCostChangeWrapper = useCallback(
|
||||
(idx: number) => (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const rawValue = e.target.value.replace(/[^\d,.-]/g, '');
|
||||
const normalizedValue = rawValue.replace(/,/g, '');
|
||||
const value = parseFloat(normalizedValue) || 0;
|
||||
const value = parseFloat(e.target.value) || 0;
|
||||
handleDeliveryCostChange(idx, value);
|
||||
},
|
||||
[handleDeliveryCostChange]
|
||||
@@ -437,9 +435,7 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
|
||||
const handleDeliveryCostPerItemChangeWrapper = useCallback(
|
||||
(idx: number) => (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const rawValue = e.target.value.replace(/[^\d,.-]/g, '');
|
||||
const normalizedValue = rawValue.replace(/,/g, '');
|
||||
const value = parseFloat(normalizedValue) || 0;
|
||||
const value = parseFloat(e.target.value) || 0;
|
||||
handleDeliveryCostPerItemChange(idx, value);
|
||||
},
|
||||
[handleDeliveryCostPerItemChange]
|
||||
@@ -1389,9 +1385,10 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
value={delivery.delivery_cost || ''}
|
||||
onChange={handleDeliveryCostChangeWrapper(idx)}
|
||||
onBlur={formik.handleBlur}
|
||||
maskType='currency'
|
||||
decimals={0}
|
||||
min={0}
|
||||
decimalScale={0}
|
||||
allowNegative={false}
|
||||
thousandSeparator=','
|
||||
decimalSeparator='.'
|
||||
{...isRepeaterInputError(
|
||||
'deliveries',
|
||||
'delivery_cost',
|
||||
@@ -1411,9 +1408,10 @@ const MovementForm = ({ type = 'add', initialValues }: MovementFormProps) => {
|
||||
value={delivery.delivery_cost_per_item || ''}
|
||||
onChange={handleDeliveryCostPerItemChangeWrapper(idx)}
|
||||
onBlur={formik.handleBlur}
|
||||
maskType='currency'
|
||||
decimals={0}
|
||||
min={0}
|
||||
decimalScale={0}
|
||||
allowNegative={false}
|
||||
thousandSeparator=','
|
||||
decimalSeparator='.'
|
||||
{...isRepeaterInputError(
|
||||
'deliveries',
|
||||
'delivery_cost_per_item',
|
||||
|
||||
Reference in New Issue
Block a user