@@ -23,12 +23,44 @@ export default async function PostDetail({ params }: { params: any }) {
|
||||
const parsed = settingRow ? JSON.parse(settingRow.value as string) : {};
|
||||
const showBanner: boolean = parsed.showBanner ?? true;
|
||||
|
||||
// 현재 게시글이 속한 카테고리의 보드들을 서브카테고리로 구성
|
||||
let subItems:
|
||||
| { id: string; name: string; href: string }[]
|
||||
| undefined = undefined;
|
||||
if (post?.boardId) {
|
||||
const categories = await prisma.boardCategory.findMany({
|
||||
where: { status: "active" },
|
||||
orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
|
||||
include: {
|
||||
boards: {
|
||||
where: { status: "active" },
|
||||
orderBy: [{ sortOrder: "asc" }, { createdAt: "asc" }],
|
||||
select: { id: true, name: true, slug: true },
|
||||
},
|
||||
},
|
||||
});
|
||||
const categoryOfPost = categories.find((c) =>
|
||||
c.boards.some((b) => b.id === post.boardId)
|
||||
);
|
||||
if (categoryOfPost) {
|
||||
subItems = categoryOfPost.boards.map((b) => ({
|
||||
id: b.id,
|
||||
name: b.name,
|
||||
href: `/boards/${b.slug}`,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* 상단 배너 */}
|
||||
{showBanner && (
|
||||
<section>
|
||||
<HeroBanner />
|
||||
<HeroBanner
|
||||
subItems={subItems}
|
||||
activeSubId={post?.boardId}
|
||||
showPartnerCats={false}
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import { useToast } from "@/app/components/ui/ToastProvider";
|
||||
import { UploadButton } from "@/app/components/UploadButton";
|
||||
import { Editor } from "@/app/components/Editor";
|
||||
import { HeroBanner } from "@/app/components/HeroBanner";
|
||||
import useSWR from "swr";
|
||||
import Link from "next/link";
|
||||
|
||||
export default function NewPostPage() {
|
||||
const router = useRouter();
|
||||
@@ -16,6 +18,7 @@ export default function NewPostPage() {
|
||||
const [form, setForm] = useState({ boardId: initialBoardId, title: "", content: "" });
|
||||
const [isSecret, setIsSecret] = useState(false);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { data: meData } = useSWR<{ user: { userId: string } | null }>("/api/me", (u: string) => fetch(u).then((r) => r.json()));
|
||||
async function submit() {
|
||||
try {
|
||||
if (!form.boardId.trim()) {
|
||||
@@ -52,6 +55,40 @@ export default function NewPostPage() {
|
||||
}
|
||||
const plainLength = (form.content || "").replace(/<[^>]*>/g, "").length;
|
||||
const MAX_LEN = 10000;
|
||||
if (!meData) {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<section>
|
||||
<HeroBanner />
|
||||
</section>
|
||||
<section className="mx-auto max-w-2xl bg-white rounded-2xl border border-neutral-300 px-6 sm:px-8 py-8 text-center">
|
||||
<div className="text-lg font-semibold text-neutral-900">확인 중...</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (!meData.user) {
|
||||
const next = `/posts/new${sp.toString() ? `?${sp.toString()}` : ""}`;
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<section>
|
||||
<HeroBanner />
|
||||
</section>
|
||||
<section className="mx-auto max-w-2xl bg-white rounded-2xl border border-neutral-300 px-6 sm:px-8 py-8 text-center">
|
||||
<div className="text-[22px] md:text-[26px] font-semibold text-neutral-900">로그인이 필요합니다</div>
|
||||
<p className="mt-2 text-neutral-600">게시글 작성은 로그인 후 이용할 수 있어요.</p>
|
||||
<div className="mt-6">
|
||||
<Link
|
||||
href={`/login?next=${encodeURIComponent(next)}`}
|
||||
className="inline-flex items-center px-5 h-12 rounded-xl border border-neutral-300 text-neutral-800 hover:bg-neutral-100"
|
||||
>
|
||||
로그인 하러 가기
|
||||
</Link>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<section>
|
||||
|
||||
Reference in New Issue
Block a user