Compare commits
3 Commits
0bf270d884
...
98e2f5608d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98e2f5608d | ||
|
|
d54ad82095 | ||
|
|
9c28d50890 |
@@ -369,6 +369,19 @@ async function seedPartnerShops() {
|
||||
});
|
||||
}
|
||||
|
||||
async function seedBanners() {
|
||||
// 기존 배너 정리 후 5개만 채움
|
||||
await prisma.banner.deleteMany({});
|
||||
const items = Array.from({ length: 5 }).map((_, i) => ({
|
||||
title: `메인 배너 ${i + 1}`,
|
||||
imageUrl: "/sample.jpg",
|
||||
linkUrl: "/",
|
||||
sortOrder: i + 1,
|
||||
active: true,
|
||||
}));
|
||||
await prisma.banner.createMany({ data: items });
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await upsertRoles();
|
||||
const admin = await upsertAdmin();
|
||||
@@ -379,6 +392,7 @@ async function main() {
|
||||
const boards = await upsertBoards(admin, categoryMap);
|
||||
await createPostsForAllBoards(boards, 100, admin);
|
||||
await seedPartnerShops();
|
||||
await seedBanners();
|
||||
|
||||
await seedPolicies();
|
||||
|
||||
|
||||
@@ -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) => (
|
||||
|
||||
@@ -132,7 +132,7 @@ export function HeroBanner({ subItems, activeSubId }: { subItems?: SubItem[]; ac
|
||||
|
||||
{/* Pagination - Figma 스타일: 활성은 주황 바, 비활성은 회색 점 (배너 위에 오버랩) */}
|
||||
{numSlides > 1 && (
|
||||
<div className="pointer-events-auto absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-[6px]">
|
||||
<div className="pointer-events-auto absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-[10px]">
|
||||
{banners.map((_, i) => (
|
||||
<button
|
||||
key={i}
|
||||
@@ -141,8 +141,8 @@ export function HeroBanner({ subItems, activeSubId }: { subItems?: SubItem[]; ac
|
||||
onClick={() => goTo(i)}
|
||||
className={
|
||||
activeIndex === i
|
||||
? "h-[4px] w-[18px] rounded-full bg-[#F94B37]"
|
||||
: "h-[6px] w-[6px] rounded-full bg-[rgba(255,255,255,0.6)] hover:bg-white"
|
||||
? "h-[6px] w-[24px] rounded-full bg-[#F94B37]"
|
||||
: "h-[10px] w-[10px] rounded-full bg-[rgba(255,255,255,0.7)] hover:bg-white"
|
||||
}
|
||||
/>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user