asi-calculator/components/Result.tsx

42 lines
935 B
TypeScript
Raw Normal View History

2024-03-29 21:37:30 +01:00
import styles from './Result.module.css'
2024-03-29 22:54:07 +01:00
import { formatNumber } from '../utils'
2024-03-30 02:03:43 +01:00
import Image from 'next/image'
2024-03-29 21:37:30 +01:00
2024-03-29 19:54:14 +01:00
type Props = {
2024-03-30 02:03:43 +01:00
tokenSymbol: string
tokenAddress: string
2024-03-29 19:54:14 +01:00
amount: number
amountAsi: number
amountFiat: number
}
2024-03-30 02:03:43 +01:00
export function Result({
tokenSymbol,
tokenAddress,
amount,
amountAsi,
amountFiat
}: Props) {
2024-03-29 19:54:14 +01:00
return (
2024-03-29 21:37:30 +01:00
<div className={styles.result}>
<p>
2024-03-30 02:03:43 +01:00
<span className={styles.logo} data-symbol={tokenSymbol}>
<Image
src={`https://tokens.1inch.io/${tokenAddress}.png`}
width={24}
height={24}
alt={tokenSymbol}
/>
</span>
{formatNumber(amount, tokenSymbol)}
</p>
<p className={styles.conversion}>
2024-03-29 22:54:07 +01:00
{' '}
<strong title={`${amountAsi}`}>{formatNumber(amountAsi, 'ASI')}</strong>{' '}
= <strong>{formatNumber(amountFiat, 'USD')}</strong>
2024-03-29 21:37:30 +01:00
</p>
</div>
2024-03-29 19:54:14 +01:00
)
}