@@ -4,15 +4,17 @@ import { useParams } from "react-router-dom";
44import { formatEther } from "viem" ;
55import { useDebounce } from "react-use" ;
66import { useAccount } from "wagmi" ;
7- import { Field } from "@kleros/ui- components-library " ;
7+ import { NumberInputField } from "components/NumberInputField " ;
88import { useParsedAmount } from "hooks/useParsedAmount" ;
99import { useCourtDetails } from "hooks/queries/useCourtDetails" ;
1010import { useKlerosCoreGetJurorBalance , usePnkBalanceOf } from "hooks/contracts/generated" ;
1111import StakeWithdrawButton , { ActionType } from "./StakeWithdrawButton" ;
12+ import { formatPNK , roundNumberDown } from "utils/format" ;
1213import { isUndefined } from "utils/index" ;
14+ import { commify , uncommify } from "utils/commify" ;
1315import { EnsureChain } from "components/EnsureChain" ;
1416
15- const StyledField = styled ( Field ) `
17+ const StyledField = styled ( NumberInputField ) `
1618 width: 100%;
1719 height: fit-content;
1820` ;
@@ -53,7 +55,7 @@ const InputDisplay: React.FC<IInputDisplay> = ({
5355} ) => {
5456 const [ debouncedAmount , setDebouncedAmount ] = useState ( "" ) ;
5557 useDebounce ( ( ) => setDebouncedAmount ( amount ) , 500 , [ amount ] ) ;
56- const parsedAmount = useParsedAmount ( debouncedAmount ) ;
58+ const parsedAmount = useParsedAmount ( uncommify ( debouncedAmount ) ) ;
5759
5860 const { id } = useParams ( ) ;
5961 const { data : courtDetails } = useCourtDetails ( id ) ;
@@ -63,13 +65,13 @@ const InputDisplay: React.FC<IInputDisplay> = ({
6365 args : [ address ?? "0x" ] ,
6466 watch : true ,
6567 } ) ;
66- const parsedBalance = formatEther ( balance ?? 0n ) ;
68+ const parsedBalance = formatPNK ( balance ?? 0n , 0 , true ) ;
6769 const { data : jurorBalance } = useKlerosCoreGetJurorBalance ( {
6870 enabled : ! isUndefined ( address ) ,
6971 args : [ address , id ] ,
7072 watch : true ,
7173 } ) ;
72- const parsedStake = formatEther ( jurorBalance ?. [ 0 ] || 0n ) ;
74+ const parsedStake = formatPNK ( jurorBalance ?. [ 0 ] || 0n , 0 , true ) ;
7375 const isStaking = action === ActionType . stake ;
7476
7577 return (
@@ -87,10 +89,9 @@ const InputDisplay: React.FC<IInputDisplay> = ({
8789 </ LabelArea >
8890 < InputArea >
8991 < StyledField
90- type = "number"
91- value = { amount }
92+ value = { uncommify ( amount ) }
9293 onChange = { ( e ) => {
93- setAmount ( e . target . value ) ;
94+ setAmount ( e ) ;
9495 } }
9596 placeholder = { isStaking ? "Amount to stake" : "Amount to withdraw" }
9697 message = {
@@ -101,7 +102,7 @@ const InputDisplay: React.FC<IInputDisplay> = ({
101102 courtDetails ?. court . minStake ?? 0n
102103 ) } PNK.`
103104 }
104- variant = "info"
105+ formatter = { ( number : string ) => commify ( roundNumberDown ( Number ( number ) ) ) }
105106 />
106107 < EnsureChain >
107108 < StakeWithdrawButton
0 commit comments