mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-05-18 23:42:24 +00:00
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import prisma from "@/lib/prisma";
|
|
import { notFound } from "next/navigation";
|
|
import { ProblemStoreProvider } from "@/providers/problem-store-provider";
|
|
import { PlaygroundHeader } from "@/components/features/playground/header";
|
|
|
|
interface ProblemProps {
|
|
params: Promise<{ id: string }>;
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export default async function ProblemLayout({
|
|
params,
|
|
children,
|
|
}: ProblemProps) {
|
|
const { id } = await params;
|
|
|
|
const [problemData, editorLanguageConfigs, languageServerConfigs] =
|
|
await Promise.all([
|
|
prisma.problem.findUnique({
|
|
where: { id },
|
|
include: {
|
|
templates: true,
|
|
testcases: {
|
|
include: {
|
|
data: true,
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
prisma.editorLanguageConfig.findMany(),
|
|
prisma.languageServerConfig.findMany(),
|
|
]);
|
|
|
|
if (!problemData) {
|
|
return notFound();
|
|
}
|
|
|
|
const { templates, testcases, ...problemWithoutTemplates } = problemData;
|
|
|
|
return (
|
|
<div className="flex flex-col h-screen">
|
|
<ProblemStoreProvider
|
|
problemId={id}
|
|
problem={problemWithoutTemplates}
|
|
templates={templates}
|
|
testcases={testcases}
|
|
editorLanguageConfigs={editorLanguageConfigs}
|
|
languageServerConfigs={languageServerConfigs}
|
|
>
|
|
<PlaygroundHeader />
|
|
<main className="flex flex-grow overflow-y-hidden p-2.5 pt-0">
|
|
{children}
|
|
</main>
|
|
</ProblemStoreProvider>
|
|
</div>
|
|
);
|
|
}
|