crush-level-web/src/app/(main)/user/[userId]/components/GiftGrid.tsx

54 lines
1.9 KiB
TypeScript
Raw Normal View History

2025-11-28 06:31:36 +00:00
'use client'
import Empty from '@/components/ui/empty'
import { useGetAIUserGifts } from '@/hooks/aiUser'
import { formatNumberToKMB } from '@/lib/utils'
import Image from 'next/image'
2025-11-13 08:38:25 +00:00
export function GiftGrid({ userId }: { userId: string }) {
2025-11-28 06:31:36 +00:00
const { data } = useGetAIUserGifts({ aiId: Number(userId), page: { pn: 1, ps: 100 } })
const { datas } = data || {}
2025-11-13 08:38:25 +00:00
if (datas && !datas.length) {
return (
2025-11-28 06:31:36 +00:00
<div className="flex w-full flex-col items-start justify-start gap-4 rounded-2xl bg-[#352e3e] p-6">
<h3 className="font-['Poppins'] text-[20px] leading-[24px] font-semibold text-white">
2025-11-13 08:38:25 +00:00
Gifts
</h3>
2025-11-28 06:31:36 +00:00
<div className="w-full py-20">
2025-11-13 08:38:25 +00:00
<Empty title="No gifts yet" />
</div>
</div>
)
}
return (
2025-11-28 06:31:36 +00:00
<div className="flex w-full flex-col items-start justify-start gap-4 rounded-2xl bg-[#352e3e] p-6">
<h3 className="font-['Poppins'] text-[20px] leading-[24px] font-semibold text-white">
2025-11-13 08:38:25 +00:00
Gifts
</h3>
2025-11-28 06:31:36 +00:00
<div className="grid w-full gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6">
2025-11-13 08:38:25 +00:00
{datas?.map((gift) => (
2025-11-28 06:31:36 +00:00
<div key={gift.id} className="flex flex-col items-start justify-start gap-1">
<div className="bg-surface-nest-normal relative flex w-full items-center justify-center rounded-sm pb-[100%]">
2025-11-13 08:38:25 +00:00
<div className="absolute inset-0 flex items-center justify-center p-4">
2025-11-28 06:31:36 +00:00
<Image
src={gift.icon ?? ''}
alt={gift.name ?? ''}
width={100}
height={100}
className="object-cover"
/>
2025-11-13 08:38:25 +00:00
</div>
</div>
2025-11-28 06:31:36 +00:00
<div className="txt-label-m text-txt-primary-normal w-full text-center">
2025-11-13 08:38:25 +00:00
{gift.name} X{formatNumberToKMB(gift.getNum ?? 0)}
</div>
</div>
))}
</div>
</div>
2025-11-28 06:31:36 +00:00
)
}