main
This commit is contained in:
@@ -10,7 +10,6 @@ export default async function BoardDetail({ params, searchParams }: { params: an
|
||||
const sp = searchParams?.then ? await searchParams : searchParams;
|
||||
const idOrSlug = p.id as string;
|
||||
const sort = (sp?.sort as "recent" | "popular" | undefined) ?? "recent";
|
||||
const period = (sp?.period as string | undefined) ?? "monthly";
|
||||
// 보드 slug 조회 (새 글 페이지 프리셋 전달)
|
||||
const h = await headers();
|
||||
const host = h.get("host") ?? "localhost:3000";
|
||||
@@ -32,10 +31,13 @@ export default async function BoardDetail({ params, searchParams }: { params: an
|
||||
|
||||
let rankingItems: { userId: string; nickname: string; points: number }[] = [];
|
||||
if (isSpecialRanking) {
|
||||
const rankingUrl = new URL(`/api/ranking?period=${encodeURIComponent(period)}`, base).toString();
|
||||
const rankingRes = await fetch(rankingUrl, { cache: "no-store" });
|
||||
const rankingData = await rankingRes.json().catch(() => ({ items: [] }));
|
||||
rankingItems = rankingData?.items ?? [];
|
||||
const topUsers = await prisma.user.findMany({
|
||||
select: { userId: true, nickname: true, points: true },
|
||||
where: { status: "active" },
|
||||
orderBy: { points: "desc" },
|
||||
take: 100,
|
||||
});
|
||||
rankingItems = topUsers.map((u) => ({ userId: u.userId, nickname: u.nickname, points: u.points }));
|
||||
}
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
@@ -49,18 +51,12 @@ export default async function BoardDetail({ params, searchParams }: { params: an
|
||||
|
||||
{/* 검색/필터 툴바 + 리스트 */}
|
||||
<section>
|
||||
<BoardToolbar boardId={board?.slug} />
|
||||
{!isSpecialRanking && <BoardToolbar boardId={board?.slug} />}
|
||||
<div className="p-0">
|
||||
{isSpecialRanking ? (
|
||||
<div className="rounded-xl border border-neutral-200 overflow-hidden">
|
||||
<div className="px-4 py-3 border-b border-neutral-200 flex items-center justify-between bg-[#f6f4f4]">
|
||||
<h2 className="text-sm text-neutral-700">포인트 랭킹 ({period})</h2>
|
||||
<div className="text-xs text-neutral-500 flex gap-2">
|
||||
<a href={`?period=daily`} className={`px-2 py-0.5 rounded ${period === "daily" ? "bg-neutral-900 text-white" : "bg-white border border-neutral-300"}`}>일간</a>
|
||||
<a href={`?period=weekly`} className={`px-2 py-0.5 rounded ${period === "weekly" ? "bg-neutral-900 text-white" : "bg-white border border-neutral-300"}`}>주간</a>
|
||||
<a href={`?period=monthly`} className={`px-2 py-0.5 rounded ${period === "monthly" ? "bg-neutral-900 text-white" : "bg-white border border-neutral-300"}`}>월간</a>
|
||||
<a href={`?period=all`} className={`px-2 py-0.5 rounded ${period === "all" ? "bg-neutral-900 text-white" : "bg-white border border-neutral-300"}`}>전체</a>
|
||||
</div>
|
||||
<h2 className="text-sm text-neutral-700">포인트 랭킹</h2>
|
||||
</div>
|
||||
<ol className="divide-y divide-neutral-200">
|
||||
{rankingItems.map((i, idx) => (
|
||||
|
||||
Reference in New Issue
Block a user