diff --git a/src/components/CryptoInput/index.tsx b/src/components/CryptoInput/index.tsx index cc63581..682cf07 100644 --- a/src/components/CryptoInput/index.tsx +++ b/src/components/CryptoInput/index.tsx @@ -14,91 +14,111 @@ export const CryptoInput: React.FC = ({ t.CurrencyTypeEnum.NEAR ) const [fiatValue, setFiatValue] = React.useState(0) + const isNear = currency === t.CurrencyTypeEnum.NEAR const updateFiatValues = async () => { - const newFiatValue = await fetchFiatValue() + const newFiatValue = isNear ? await fetchFiatValue() : 1 const newTotalFiatValue = newFiatValue * Number(value) setFiatValue(newTotalFiatValue) } // Todo: make a redux value for it, updated every X minutes React.useEffect(() => { - updateFiatValues() - }, [value]) + if (value) { + updateFiatValues() + } + }, [value, isNear]) return ( - - - { - onChange(e?.target?.value) - }} - /> - {maxValue ? ( + <> + {maxValue ? ( + + + balance: {Number(maxValue || 0).toFixed(3)} +