diff --git a/next-app/apps/web/src/app/[boardSlug]/[wrId]/edit/page.tsx b/next-app/apps/web/src/app/[boardSlug]/[wrId]/edit/page.tsx new file mode 100644 index 0000000..f5f606c --- /dev/null +++ b/next-app/apps/web/src/app/[boardSlug]/[wrId]/edit/page.tsx @@ -0,0 +1,7 @@ +import { StubPage } from '@/lib/page-shells'; +export default async function Page({ params }: { params: Promise<{ boardSlug: string; wrId: string }> }) { + const { boardSlug, wrId } = await params; + return +

대상: /{boardSlug}/{wrId}

+
; +} diff --git a/next-app/apps/web/src/app/[boardSlug]/[wrId]/page.tsx b/next-app/apps/web/src/app/[boardSlug]/[wrId]/page.tsx index 89e0a1b..d034a0a 100644 --- a/next-app/apps/web/src/app/[boardSlug]/[wrId]/page.tsx +++ b/next-app/apps/web/src/app/[boardSlug]/[wrId]/page.tsx @@ -1,7 +1,8 @@ import { notFound } from 'next/navigation'; import { getBoardMeta, getPost } from '@/lib/legacy-board'; import { getThemeForPath } from '@/lib/theme'; -import { headers } from 'next/headers'; +import { getCurrentSiteUser, getCurrentPathname } from '@/lib/page-data'; +import { legacySql } from '@slot/db/legacy'; export const dynamic = 'force-dynamic'; @@ -11,27 +12,55 @@ export default async function PostPage({ params }: { params: Promise<{ boardSlug if (!meta) return notFound(); const post = await getPost(boardSlug, wrId); if (!post) return notFound(); - const h = await headers(); - const theme = await getThemeForPath(h.get('x-pathname') ?? `/${boardSlug}/${wrId}`); + const [theme, user] = await Promise.all([ + getThemeForPath(await getCurrentPathname()), + getCurrentSiteUser(), + ]); + + // hit++ async (don't block render) + legacySql`UPDATE inspection2.${legacySql(`g5_write_${boardSlug.replace(/[^a-z0-9_]/gi,'')}`)} SET wr_hit = wr_hit + 1 WHERE wr_id = ${parseInt(wrId, 10)}`.catch(() => {}); + + // Resolve author authorization + const authorRows = await legacySql<{ mb_id: string }[]>` + SELECT mb_id FROM inspection2.${legacySql(`g5_write_${boardSlug.replace(/[^a-z0-9_]/gi,'')}`)} + WHERE wr_id = ${parseInt(wrId, 10)} + `.catch(() => []); + const authorMbId = authorRows[0]?.mb_id ?? ''; + const isOwner = user?.loginId === authorMbId && !!authorMbId; + const isAdmin = (user?.level ?? 0) >= 10; + const PostView = theme.slots.PostView; const commentsTree = (
-

댓글 ({post.comments.length})

- {post.comments.length === 0 &&

아직 댓글이 없습니다.

} +

댓글 ({post.comments.length})

+ {post.comments.length === 0 &&

아직 댓글이 없습니다. 첫 댓글을 남겨보세요.

} {post.comments.map((c, i) => ( -
-
- {c.authorName} · {new Date(c.createdAt).toLocaleString('ko-KR')} +
+
+ {c.authorName} · {new Date(c.createdAt).toLocaleString('ko-KR')}
-
+
))} + {user ? ( +
+ +