mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-07-04 01:10:53 +00:00
feat(problems): add published check in problem layout
This commit is contained in:
parent
7cda49116e
commit
c6c70e5491
@ -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 />
|
||||||
|
Loading…
Reference in New Issue
Block a user