feat(problems): add published check in problem layout

This commit is contained in:
cfngc4594 2025-06-21 00:35:20 +08:00
parent 7cda49116e
commit c6c70e5491

View File

@ -1,3 +1,4 @@
import prisma from "@/lib/prisma";
import { notFound } from "next/navigation"; import { notFound } from "next/navigation";
import { ProblemHeader } from "@/features/problems/components/header"; import { ProblemHeader } from "@/features/problems/components/header";
@ -13,6 +14,19 @@ const Layout = async ({ children, params }: LayoutProps) => {
return notFound(); return notFound();
} }
const problem = await prisma.problem.findUnique({
select: {
isPublished: true,
},
where: {
id: problemId,
},
});
if (!problem?.isPublished) {
return notFound();
}
return ( return (
<div className="flex flex-col h-screen"> <div className="flex flex-col h-screen">
<ProblemHeader /> <ProblemHeader />