8.3 회원랭킹: 기간별 랭킹 집계/캐싱/페이지네이션/정렬 옵션

This commit is contained in:
koreacomp5
2025-10-09 17:25:17 +09:00
parent 1e5368029b
commit d7b6af91e5
2 changed files with 56 additions and 0 deletions

29
src/app/ranking/page.tsx Normal file
View File

@@ -0,0 +1,29 @@
"use client";
import useSWR from "swr";
const fetcher = (url: string) => fetch(url).then((r) => r.json());
export default function RankingPage({ searchParams }: { searchParams?: { period?: string } }) {
const period = searchParams?.period ?? "monthly";
const { data } = useSWR<{ period: string; items: { userId: string; nickname: string; points: number }[] }>(`/api/ranking?period=${period}`, fetcher);
return (
<div>
<h1></h1>
<div style={{ display: "flex", gap: 8, margin: "8px 0" }}>
<a href={`/ranking?period=daily`}></a>
<a href={`/ranking?period=weekly`}></a>
<a href={`/ranking?period=monthly`}></a>
<a href={`/ranking?period=all`}></a>
</div>
<ol>
{(data?.items ?? []).map((i) => (
<li key={i.userId}>
<strong>{i.nickname}</strong> {i.points}
</li>
))}
</ol>
</div>
);
}