better is number check
This commit is contained in:
parent
5f61ad117b
commit
7d15e8e798
|
@ -62,10 +62,13 @@ const CreateAccountForm = ({
|
||||||
const newAccount = mangoAccounts.find(
|
const newAccount = mangoAccounts.find(
|
||||||
(acc) => acc.accountNum === newAccountNum
|
(acc) => acc.accountNum === newAccountNum
|
||||||
)
|
)
|
||||||
set((s) => {
|
if (newAccount) {
|
||||||
s.mangoAccount.current = newAccount
|
await newAccount.reloadAccountData(client)
|
||||||
s.mangoAccounts = mangoAccounts
|
set((s) => {
|
||||||
})
|
s.mangoAccount.current = newAccount
|
||||||
|
s.mangoAccounts = mangoAccounts
|
||||||
|
})
|
||||||
|
}
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
notify({
|
notify({
|
||||||
title: t('new-account-success'),
|
title: t('new-account-success'),
|
||||||
|
|
|
@ -229,7 +229,7 @@ function BorrowModal({ isOpen, onClose, token }: ModalCombinedProps) {
|
||||||
placeholder="0.00"
|
placeholder="0.00"
|
||||||
value={inputAmount}
|
value={inputAmount}
|
||||||
onValueChange={(e: NumberFormatValues) =>
|
onValueChange={(e: NumberFormatValues) =>
|
||||||
setInputAmount(Number(e.value) ? e.value : '')
|
setInputAmount(!Number.isNaN(Number(e.value)) ? e.value : '')
|
||||||
}
|
}
|
||||||
isAllowed={withValueLimit}
|
isAllowed={withValueLimit}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -98,7 +98,7 @@ function DepositModal({ isOpen, onClose, token }: ModalCombinedProps) {
|
||||||
selectedToken === 'SOL' ? tokenMax.maxAmount - 0.05 : tokenMax.maxAmount
|
selectedToken === 'SOL' ? tokenMax.maxAmount - 0.05 : tokenMax.maxAmount
|
||||||
setInputAmount(max.toString())
|
setInputAmount(max.toString())
|
||||||
setSizePercentage('100')
|
setSizePercentage('100')
|
||||||
}, [tokenMax])
|
}, [tokenMax, selectedToken])
|
||||||
|
|
||||||
const handleSizePercentage = useCallback(
|
const handleSizePercentage = useCallback(
|
||||||
(percentage: string) => {
|
(percentage: string) => {
|
||||||
|
@ -113,7 +113,7 @@ function DepositModal({ isOpen, onClose, token }: ModalCombinedProps) {
|
||||||
|
|
||||||
setInputAmount(amount.toString())
|
setInputAmount(amount.toString())
|
||||||
},
|
},
|
||||||
[tokenMax]
|
[tokenMax, selectedToken]
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -294,9 +294,9 @@ function DepositModal({ isOpen, onClose, token }: ModalCombinedProps) {
|
||||||
className="w-full rounded-lg rounded-l-none border border-th-bkg-4 bg-th-bkg-1 p-3 text-right font-mono text-xl tracking-wider text-th-fgd-1 focus:outline-none"
|
className="w-full rounded-lg rounded-l-none border border-th-bkg-4 bg-th-bkg-1 p-3 text-right font-mono text-xl tracking-wider text-th-fgd-1 focus:outline-none"
|
||||||
placeholder="0.00"
|
placeholder="0.00"
|
||||||
value={inputAmount}
|
value={inputAmount}
|
||||||
onValueChange={(e: NumberFormatValues) =>
|
onValueChange={(e: NumberFormatValues) => {
|
||||||
setInputAmount(Number(e.value) ? e.value : '')
|
setInputAmount(!Number.isNaN(Number(e.value)) ? e.value : '')
|
||||||
}
|
}}
|
||||||
isAllowed={withValueLimit}
|
isAllowed={withValueLimit}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -237,7 +237,9 @@ function WithdrawModal({ isOpen, onClose, token }: ModalCombinedProps) {
|
||||||
placeholder="0.00"
|
placeholder="0.00"
|
||||||
value={inputAmount}
|
value={inputAmount}
|
||||||
onValueChange={(e: NumberFormatValues) =>
|
onValueChange={(e: NumberFormatValues) =>
|
||||||
setInputAmount(Number(e.value) ? e.value : '')
|
setInputAmount(
|
||||||
|
!Number.isNaN(Number(e.value)) ? e.value : ''
|
||||||
|
)
|
||||||
}
|
}
|
||||||
isAllowed={withValueLimit}
|
isAllowed={withValueLimit}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -94,7 +94,7 @@ const AdvancedTradeForm = () => {
|
||||||
if (info.source !== 'event') return
|
if (info.source !== 'event') return
|
||||||
set((s) => {
|
set((s) => {
|
||||||
s.tradeForm.price = e.value
|
s.tradeForm.price = e.value
|
||||||
if (s.tradeForm.baseSize && Number(e.value)) {
|
if (s.tradeForm.baseSize && !Number.isNaN(Number(e.value))) {
|
||||||
s.tradeForm.quoteSize = (
|
s.tradeForm.quoteSize = (
|
||||||
parseFloat(e.value) * parseFloat(s.tradeForm.baseSize)
|
parseFloat(e.value) * parseFloat(s.tradeForm.baseSize)
|
||||||
).toString()
|
).toString()
|
||||||
|
@ -111,7 +111,7 @@ const AdvancedTradeForm = () => {
|
||||||
set((s) => {
|
set((s) => {
|
||||||
s.tradeForm.baseSize = e.value
|
s.tradeForm.baseSize = e.value
|
||||||
|
|
||||||
if (s.tradeForm.price && Number(e.value)) {
|
if (s.tradeForm.price && !Number.isNaN(Number(e.value))) {
|
||||||
s.tradeForm.quoteSize = (
|
s.tradeForm.quoteSize = (
|
||||||
parseFloat(s.tradeForm.price) * parseFloat(e.value)
|
parseFloat(s.tradeForm.price) * parseFloat(e.value)
|
||||||
).toString()
|
).toString()
|
||||||
|
|
Loading…
Reference in New Issue