mirror of
https://github.com/cerc-io/mars-interface.git
synced 2025-08-08 10:24:06 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { Coin } from '@cosmjs/stargate'
|
|
import { AnimatedNumber } from 'components/common'
|
|
import useStore from 'store'
|
|
|
|
interface Props {
|
|
coin: Coin
|
|
prefixClass?: string
|
|
valueClass?: string
|
|
isApproximation?: boolean
|
|
className?: string
|
|
}
|
|
|
|
export const DisplayCurrency = ({
|
|
coin,
|
|
prefixClass,
|
|
valueClass,
|
|
isApproximation,
|
|
className,
|
|
}: Props) => {
|
|
const networkConfig = useStore((s) => s.networkConfig)
|
|
const convertToDisplayCurrency = useStore((s) => s.convertToDisplayCurrency)
|
|
const amount = convertToDisplayCurrency(coin)
|
|
const displayCurrency = networkConfig?.displayCurrency
|
|
|
|
if (!displayCurrency) return null
|
|
|
|
return (
|
|
<div className={className}>
|
|
{displayCurrency.prefix && (
|
|
<span className={prefixClass}>
|
|
{displayCurrency.prefix}
|
|
{isApproximation && '~'}
|
|
</span>
|
|
)}
|
|
<span className={valueClass}>
|
|
<AnimatedNumber
|
|
amount={amount}
|
|
minDecimals={displayCurrency.decimals}
|
|
maxDecimals={displayCurrency.decimals}
|
|
/>
|
|
</span>
|
|
{displayCurrency.suffix && <span className={valueClass}>{' ' + displayCurrency.suffix}</span>}
|
|
</div>
|
|
)
|
|
}
|