"use client" import { useRef, useState } from "react" import { RewardIcon } from "@/components/Blocks/DynamicContent/Rewards/RewardIcon" import Pagination from "@/components/MyPages/Pagination" import Grids from "@/components/TempDesignSystem/Grids" import Title from "@/components/TempDesignSystem/Text/Title" import Redeem from "./Redeem" import styles from "./current.module.css" import type { CurrentRewardsClientProps } from "@/types/components/myPages/myPage/accountPage" export default function ClientCurrentRewards({ rewards, pageSize, showRedeem, }: CurrentRewardsClientProps) { const containerRef = useRef(null) const [currentPage, setCurrentPage] = useState(1) const totalPages = Math.ceil(rewards.length / pageSize) const startIndex = (currentPage - 1) * pageSize const endIndex = startIndex + pageSize const currentRewards = rewards.slice(startIndex, endIndex) function handlePageChange(page: number) { requestAnimationFrame(() => { setCurrentPage(page) containerRef.current?.scrollIntoView({ behavior: "smooth", block: "start", inline: "nearest", }) }) } return (
{currentRewards.map((reward, idx) => (
{reward.label}
{showRedeem && "redeem_description" in reward && (
)}
))}
{totalPages > 1 && ( )}
) }