asi-calculator/components/ResultRow/ResultRow.tsx

44 lines
972 B
TypeScript
Raw Normal View History

2024-03-30 19:11:24 +01:00
import styles from './ResultRow.module.css'
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>
2024-03-30 02:20:15 +01:00
{formatNumber(amount || 0, tokenSymbol)}
2024-03-30 02:03:43 +01:00
</p>
<p className={styles.conversion}>
2024-03-29 22:54:07 +01:00
{' '}
2024-03-30 02:20:15 +01:00
<strong title={`${amountAsi}`}>
{formatNumber(amountAsi || 0, 'ASI')}
</strong>{' '}
= <strong>{formatNumber(amountFiat || 0, 'USD')}</strong>
2024-03-29 21:37:30 +01:00
</p>
</div>
2024-03-29 19:54:14 +01:00
)
}