import { useXuTransactions } from '@/hooks/use-gamification' import { useGamification } from '@/hooks/use-gamification' import type { XuTransactionType } from '@/types' const TX_ICON: Record = { earn_welcome: 'redeem', earn_daily: 'check_circle', earn_streak: 'local_fire_department', earn_ads: 'play_circle', spend_freeze: 'ac_unit', spend_writing: 'auto_fix_high', spend_test: 'quiz', } export function XuWalletCard() { const { data: gam } = useGamification() const { data: txs, isLoading } = useXuTransactions(5) const balance = gam?.xu ?? 0 return (
{/* Decorative blobs */}

Ví Xu của bạn

{balance.toLocaleString('vi-VN')} Xu
{isLoading && ( <> {[1, 2].map((i) => (
))} )} {!isLoading && txs && txs.length === 0 && (
Chưa có giao dịch nào
)} {!isLoading && txs && txs.map((t) => (
{TX_ICON[t.type] ?? 'swap_horiz'} {t.description ?? t.type}
0 ? 'text-green-300' : 'text-red-300'}`}> {t.amount > 0 ? `+${t.amount}` : t.amount} Xu
))}
) }