11import WeightFormat from '@/components/presentation/weight-format' ;
22import { spacing } from '@/hooks/useAppTheme' ;
33import { useWeightSuffix } from '@/hooks/useWeightSuffix' ;
4+ import {
5+ localeFormatBigNumber ,
6+ localeParseBigNumber ,
7+ } from '@/utils/locale-bignumber' ;
48import { T } from '@tolgee/react' ;
59import BigNumber from 'bignumber.js' ;
610import { ReactNode , useEffect , useState } from 'react' ;
@@ -35,14 +39,14 @@ type WeightDialogProps = {
3539
3640export default function WeightDialog ( props : WeightDialogProps ) {
3741 const theme = useTheme ( ) ;
38- const [ text , setText ] = useState ( props . weight ?. toFormat ( ) ?? '' ) ;
42+ const [ text , setText ] = useState ( localeFormatBigNumber ( props . weight ) ) ;
3943 const [ editorWeight , setEditorWeight ] = useState < BigNumber | undefined > (
4044 props . weight ,
4145 ) ;
4246 const weightSuffix = useWeightSuffix ( ) ;
4347
4448 useEffect ( ( ) => {
45- setText ( props . weight ?. toFormat ( ) ?? '' ) ;
49+ setText ( localeFormatBigNumber ( props . weight ) ) ;
4650 setEditorWeight ( props . weight ) ;
4751 } , [ props . open , props . weight , setText ] ) ;
4852
@@ -55,14 +59,14 @@ export default function WeightDialog(props: WeightDialogProps) {
5559 return ;
5660 }
5761 setEditorWeight ( editorWeight . plus ( nonZeroIncrement ) ) ;
58- setText ( editorWeight . plus ( nonZeroIncrement ) . toFormat ( ) ) ;
62+ setText ( localeFormatBigNumber ( editorWeight . plus ( nonZeroIncrement ) ) ) ;
5963 } ;
6064 const decrementWeight = ( ) => {
6165 if ( editorWeight === undefined ) {
6266 return ;
6367 }
6468 setEditorWeight ( editorWeight . minus ( nonZeroIncrement ) ) ;
65- setText ( editorWeight . minus ( nonZeroIncrement ) . toFormat ( ) ) ;
69+ setText ( localeFormatBigNumber ( editorWeight . minus ( nonZeroIncrement ) ) ) ;
6670 } ;
6771
6872 const handleTextChange = ( text : string ) => {
@@ -72,8 +76,8 @@ export default function WeightDialog(props: WeightDialogProps) {
7276 return ;
7377 }
7478
75- if ( ! BigNumber ( text ) . isNaN ( ) ) {
76- setEditorWeight ( new BigNumber ( text ) ) ;
79+ if ( ! localeParseBigNumber ( text ) . isNaN ( ) ) {
80+ setEditorWeight ( localeParseBigNumber ( text ) ) ;
7781 return ;
7882 }
7983 } ;
0 commit comments