This commit is contained in:
@@ -9,6 +9,7 @@ import { RankIcon1st } from "@/app/components/RankIcon1st";
|
||||
import { RankIcon2nd } from "@/app/components/RankIcon2nd";
|
||||
import { RankIcon3rd } from "@/app/components/RankIcon3rd";
|
||||
import { GradeIcon } from "@/app/components/GradeIcon";
|
||||
import AttendanceCalendar from "@/app/components/AttendanceCalendar";
|
||||
|
||||
// Next 15: params/searchParams가 Promise가 될 수 있어 안전 언랩 처리합니다.
|
||||
export default async function BoardDetail({ params, searchParams }: { params: any; searchParams: any }) {
|
||||
@@ -21,6 +22,14 @@ export default async function BoardDetail({ params, searchParams }: { params: an
|
||||
const host = h.get("host") ?? "localhost:3000";
|
||||
const proto = h.get("x-forwarded-proto") ?? "http";
|
||||
const base = process.env.NEXT_PUBLIC_BASE_URL || `${proto}://${host}`;
|
||||
// 로그인 여부 파악
|
||||
const cookieHeader = h.get("cookie") || "";
|
||||
const uid = cookieHeader
|
||||
.split(";")
|
||||
.map((s) => s.trim())
|
||||
.find((pair) => pair.startsWith("uid="))
|
||||
?.split("=")[1];
|
||||
const isLoggedIn = !!uid;
|
||||
const res = await fetch(new URL("/api/boards", base).toString(), { cache: "no-store" });
|
||||
const { boards } = await res.json();
|
||||
const board = (boards || []).find((b: any) => b.slug === idOrSlug || b.id === idOrSlug);
|
||||
@@ -33,12 +42,13 @@ export default async function BoardDetail({ params, searchParams }: { params: an
|
||||
const parsed = settingRow ? JSON.parse(settingRow.value as string) : {};
|
||||
const showBanner: boolean = parsed.showBanner ?? true;
|
||||
|
||||
// 리스트 뷰 타입 확인 (특수랭킹일 경우 게시글 대신 랭킹 노출)
|
||||
// 리스트 뷰 타입 확인 (특수랭킹/출석부 등)
|
||||
const boardView = await prisma.board.findUnique({
|
||||
where: { id },
|
||||
select: { listViewType: { select: { key: true } } },
|
||||
});
|
||||
const isSpecialRanking = boardView?.listViewType?.key === "list_special_rank";
|
||||
const isAttendance = boardView?.listViewType?.key === "list_special_attendance";
|
||||
|
||||
let rankingItems: { userId: string; nickname: string; points: number; profileImage: string | null; grade: number }[] = [];
|
||||
if (isSpecialRanking) {
|
||||
@@ -84,7 +94,7 @@ export default async function BoardDetail({ params, searchParams }: { params: an
|
||||
|
||||
{/* 검색/필터 툴바 + 리스트 */}
|
||||
<section className="px-[0px] md:px-[30px] ">
|
||||
{!isSpecialRanking && <BoardToolbar boardId={board?.slug} />}
|
||||
{!isSpecialRanking && !isAttendance && <BoardToolbar boardId={board?.slug} />}
|
||||
<div className="p-0">
|
||||
{isSpecialRanking ? (
|
||||
<div className="w-full">
|
||||
@@ -128,6 +138,10 @@ export default async function BoardDetail({ params, searchParams }: { params: an
|
||||
<div className="px-4 py-10 text-center text-neutral-500">랭킹 데이터가 없습니다.</div>
|
||||
)}
|
||||
</div>
|
||||
) : isAttendance ? (
|
||||
<div className="w-full py-4">
|
||||
<AttendanceCalendar isLoggedIn={isLoggedIn} />
|
||||
</div>
|
||||
) : (
|
||||
<PostList
|
||||
boardId={id}
|
||||
|
||||
Reference in New Issue
Block a user