Skip to content

Commit

Permalink
fix: use string instead of number to avoid scientific notation (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
keellyp authored Dec 9, 2024
1 parent e95c297 commit 1b4b853
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/hooks/plans/__tests__/useGraduatedChargeForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ describe('useGraduatedRange()', () => {
{
fromValue: '0',
toValue: '1',
flatAmount: 4,
flatAmount: '4',
perUnitAmount: undefined,
disabledDelete: true,
},
{
fromValue: '2',
toValue: null,
flatAmount: undefined,
perUnitAmount: 5,
perUnitAmount: '5',
disabledDelete: false,
},
])
Expand Down Expand Up @@ -506,15 +506,15 @@ describe('useGraduatedRange()', () => {
{
fromValue: '0',
toValue: '1',
flatAmount: 4,
flatAmount: '4',
perUnitAmount: undefined,
disabledDelete: true,
},
{
fromValue: '2',
toValue: null,
flatAmount: undefined,
perUnitAmount: 5,
perUnitAmount: '5',
disabledDelete: false,
},
])
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/plans/__tests__/useVolumeChargeForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ describe('useVolumeChargeForm()', () => {
await act(async () => await result.current.handleUpdate(1, 'flatAmount', '10'))
expect(result.current.tableDatas).toStrictEqual([
{ ...volumeRanges[0], disabledDelete: true },
{ ...{ ...volumeRanges[1], flatAmount: 10 }, disabledDelete: false },
{ ...{ ...volumeRanges[1], flatAmount: '10' }, disabledDelete: false },
{ ...volumeRanges[2], disabledDelete: false },
])
await act(async () => await result.current.handleUpdate(1, 'flatAmount', '1'))

await act(async () => await result.current.handleUpdate(1, 'fromValue', 5))
expect(result.current.tableDatas).toStrictEqual([
{ ...volumeRanges[0], disabledDelete: true },
{ ...{ ...volumeRanges[1], flatAmount: 1, fromValue: 5 }, disabledDelete: false },
{ ...{ ...volumeRanges[1], flatAmount: '1', fromValue: 5 }, disabledDelete: false },
{ ...volumeRanges[2], disabledDelete: false },
])
})
Expand Down Expand Up @@ -584,15 +584,15 @@ describe('useVolumeChargeForm()', () => {
await act(async () => await result.current.handleUpdate(1, 'flatAmount', '10'))
expect(result.current.tableDatas).toStrictEqual([
{ ...volumeRanges[0], disabledDelete: true },
{ ...{ ...volumeRanges[1], flatAmount: 10 }, disabledDelete: false },
{ ...{ ...volumeRanges[1], flatAmount: '10' }, disabledDelete: false },
{ ...volumeRanges[2], disabledDelete: false },
])
await act(async () => await result.current.handleUpdate(1, 'flatAmount', '1'))

await act(async () => await result.current.handleUpdate(1, 'fromValue', 5))
expect(result.current.tableDatas).toStrictEqual([
{ ...volumeRanges[0], disabledDelete: true },
{ ...{ ...volumeRanges[1], flatAmount: 1, fromValue: 5 }, disabledDelete: false },
{ ...{ ...volumeRanges[1], flatAmount: '1', fromValue: 5 }, disabledDelete: false },
{ ...volumeRanges[2], disabledDelete: false },
])
})
Expand Down
5 changes: 1 addition & 4 deletions src/hooks/plans/useGraduatedChargeForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,7 @@ export const useGraduatedChargeForm: UseGraduatedChargeForm = ({
},
handleUpdate: (rangeIndex, fieldName, value) => {
if (fieldName !== 'toValue') {
formikProps.setFieldValue(
`${formikIdentifier}.${rangeIndex}.${fieldName}`,
value !== '' ? Number(value) : value,
)
formikProps.setFieldValue(`${formikIdentifier}.${rangeIndex}.${fieldName}`, value)
} else {
const newGraduatedRanges = graduatedRanges.reduce<GraduatedRangeInput[]>(
(acc, range, i) => {
Expand Down
5 changes: 1 addition & 4 deletions src/hooks/plans/useVolumeChargeForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ export const useVolumeChargeForm: UseVolumeChargeForm = ({
},
handleUpdate: (rangeIndex, fieldName, value) => {
if (fieldName !== 'toValue') {
formikProps.setFieldValue(
`${formikIdentifier}.${rangeIndex}.${fieldName}`,
value !== '' ? Number(value) : value,
)
formikProps.setFieldValue(`${formikIdentifier}.${rangeIndex}.${fieldName}`, value)
} else {
const newVolumeRanges = volumeRanges.reduce<VolumeRangeInput[]>((acc, range, i) => {
if (rangeIndex === i) {
Expand Down

0 comments on commit 1b4b853

Please sign in to comment.