asi-calculator/components/ResultRow/ResultRow.tsx

69 lines
1.6 KiB
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-31 05:03:37 +02:00
import { ArrowRightIcon } from '@radix-ui/react-icons'
2024-03-31 16:58:26 +02:00
import { TokenLogo } from '../TokenLogo/TokenLogo'
import { Token } from '@/types'
2024-03-29 21:37:30 +01:00
2024-03-29 19:54:14 +01:00
type Props = {
2024-03-31 16:58:26 +02:00
token: Token | undefined
2024-03-29 19:54:14 +01:00
amount: number
amountAsi: number
amountFiat: number
2024-03-31 05:03:37 +02:00
amountOriginalFiat?: number
2024-03-31 05:32:11 +02:00
isValidating: boolean
2024-04-01 02:15:51 +02:00
isLoading: boolean
2024-03-29 19:54:14 +01:00
}
2024-03-30 02:03:43 +01:00
export function Result({
2024-03-31 16:58:26 +02:00
token,
2024-03-30 02:03:43 +01:00
amount,
amountAsi,
2024-03-31 05:03:37 +02:00
amountFiat,
2024-03-31 05:32:11 +02:00
amountOriginalFiat,
2024-04-01 02:15:51 +02:00
isValidating,
isLoading
2024-03-30 02:03:43 +01:00
}: Props) {
2024-04-01 02:15:51 +02:00
const feedbackClasses = isLoading
? 'isLoading'
: isValidating
? 'isValidating'
: ''
2024-03-29 19:54:14 +01:00
return (
2024-03-29 21:37:30 +01:00
<div className={styles.result}>
2024-03-31 15:24:07 +02:00
<div className={styles.resultLine}>
2024-03-31 16:58:26 +02:00
<TokenLogo token={token} />
2024-03-30 02:03:43 +01:00
2024-04-01 02:15:51 +02:00
<p>
<span className={feedbackClasses}>
{formatNumber(amount || 0, token?.symbol || '')}
</span>
</p>
2024-03-31 05:03:37 +02:00
{amountOriginalFiat ? (
2024-04-01 02:15:51 +02:00
<p>
<span className={`${styles.fiat} ${feedbackClasses}`}>
{formatNumber(amountOriginalFiat || 0, 'USD')}
</span>
</p>
2024-03-31 05:03:37 +02:00
) : null}
</div>
2024-04-01 02:15:51 +02:00
2024-03-31 15:24:07 +02:00
<div className={styles.resultLine}>
2024-03-31 05:03:37 +02:00
<ArrowRightIcon className={styles.iconArrow} />
2024-04-01 02:15:51 +02:00
<p>
<strong title={`${amountAsi}`} className={feedbackClasses}>
{formatNumber(amountAsi || 0, 'ASI')}
</strong>
</p>
<p>
<strong className={`${styles.fiat} ${feedbackClasses}`}>
{formatNumber(amountFiat || 0, 'USD')}
</strong>
</p>
2024-03-31 05:03:37 +02:00
</div>
2024-03-29 21:37:30 +01:00
</div>
2024-03-29 19:54:14 +01:00
)
}