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