asi-calculator/features/prices/components/Price/Price.tsx

27 lines
738 B
TypeScript
Raw Normal View History

import { type PriceCoingecko, useLocale, usePrices } from '@/features/prices'
import { formatFiat } from '@/lib'
import styles from './Price.module.css'
import { PriceChange } from './PriceChange'
2024-04-14 12:52:37 +02:00
export function Price({ price }: { price: PriceCoingecko }) {
const { isValidating, isLoading } = usePrices()
const locale = useLocale()
const feedbackClasses = isLoading
? 'isLoading'
: isValidating
? 'isValidating'
: ''
return (
<p className={styles.price}>
<span className={`${styles.fiat} ${feedbackClasses}`}>
2024-09-21 03:06:44 +02:00
{formatFiat(price?.usd, 'USD', locale)}
</span>
2024-04-14 12:52:37 +02:00
{price?.usd_24h_change ? (
<PriceChange priceChange={price.usd_24h_change} />
) : null}
</p>
)
}