2024-04-01 14:42:08 +02:00
|
|
|
import styles from './Result.module.css'
|
2024-04-16 12:20:29 +02:00
|
|
|
import { formatCrypto, formatFiat } from '@/lib'
|
2024-03-31 05:03:37 +02:00
|
|
|
import { ArrowRightIcon } from '@radix-ui/react-icons'
|
2024-04-01 15:23:01 +02:00
|
|
|
import { TokenLogo } from '@/components'
|
2024-03-31 16:58:26 +02:00
|
|
|
import { Token } from '@/types'
|
2024-04-16 12:20:29 +02:00
|
|
|
import { useLocale } from '@/features/prices'
|
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-16 12:20:29 +02:00
|
|
|
const locale = useLocale()
|
2024-04-01 02:15:51 +02:00
|
|
|
const feedbackClasses = isLoading
|
|
|
|
? 'isLoading'
|
|
|
|
: isValidating
|
2024-04-16 12:20:29 +02:00
|
|
|
? 'isValidating'
|
|
|
|
: ''
|
2024-04-01 02:15:51 +02:00
|
|
|
|
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>
|
2024-04-16 12:20:29 +02:00
|
|
|
<span
|
|
|
|
className={feedbackClasses}
|
|
|
|
title={`${amount} ${token?.symbol}`}
|
|
|
|
>
|
|
|
|
{formatCrypto(amount || 0, token?.symbol || '', locale)}
|
2024-04-01 02:15:51 +02:00
|
|
|
</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}`}>
|
2024-04-16 12:20:29 +02:00
|
|
|
{formatFiat(amountOriginalFiat || 0, 'USD', locale)}
|
2024-04-01 02:15:51 +02:00
|
|
|
</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-06-10 15:54:58 +02:00
|
|
|
<TokenLogo token={{ symbol: 'ASI', address: '0x' }} />
|
2024-04-01 02:15:51 +02:00
|
|
|
|
|
|
|
<p>
|
2024-04-16 12:20:29 +02:00
|
|
|
<strong title={`${amountAsi} ASI`} className={feedbackClasses}>
|
|
|
|
{formatCrypto(amountAsi || 0, 'ASI', locale)}
|
2024-04-01 02:15:51 +02:00
|
|
|
</strong>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<strong className={`${styles.fiat} ${feedbackClasses}`}>
|
2024-04-16 12:20:29 +02:00
|
|
|
{formatFiat(amountFiat || 0, 'USD', locale)}
|
2024-04-01 02:15:51 +02:00
|
|
|
</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
|
|
|
)
|
|
|
|
}
|