2025-03-20 08:12:23 +00:00
|
|
|
import prisma from "@/lib/prisma";
|
|
|
|
import { notFound } from "next/navigation";
|
2025-03-21 16:21:51 +00:00
|
|
|
import { ProblemStoreProvider } from "@/providers/problem-store-provider";
|
2025-03-16 04:05:59 +00:00
|
|
|
import { PlaygroundHeader } from "@/components/features/playground/header";
|
2025-03-08 10:00:13 +00:00
|
|
|
|
2025-04-04 09:03:55 +00:00
|
|
|
interface ProblemProps {
|
2025-03-20 08:12:23 +00:00
|
|
|
params: Promise<{ id: string }>;
|
2025-04-06 07:58:12 +00:00
|
|
|
children: React.ReactNode;
|
2025-03-08 10:00:13 +00:00
|
|
|
}
|
|
|
|
|
2025-04-04 09:03:55 +00:00
|
|
|
export default async function ProblemLayout({
|
2025-03-20 08:12:23 +00:00
|
|
|
params,
|
2025-04-06 07:58:12 +00:00
|
|
|
children,
|
2025-04-04 09:03:55 +00:00
|
|
|
}: ProblemProps) {
|
2025-03-20 08:12:23 +00:00
|
|
|
const { id } = await params;
|
|
|
|
|
2025-04-11 09:42:52 +00:00
|
|
|
const [problem, editorLanguageConfigs, languageServerConfigs, submissions] = await Promise.all([
|
2025-04-09 12:38:53 +00:00
|
|
|
prisma.problem.findUnique({
|
|
|
|
where: { id },
|
|
|
|
include: {
|
|
|
|
templates: true,
|
|
|
|
testcases: {
|
|
|
|
include: {
|
|
|
|
data: true,
|
2025-04-09 11:41:55 +00:00
|
|
|
},
|
|
|
|
},
|
2025-04-09 12:38:53 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
prisma.editorLanguageConfig.findMany(),
|
|
|
|
prisma.languageServerConfig.findMany(),
|
2025-04-11 09:42:52 +00:00
|
|
|
prisma.submission.findMany({
|
|
|
|
where: { problemId: id },
|
|
|
|
})
|
2025-04-09 12:38:53 +00:00
|
|
|
]);
|
2025-03-20 08:12:23 +00:00
|
|
|
|
2025-04-09 12:38:53 +00:00
|
|
|
if (!problem) {
|
2025-03-20 08:12:23 +00:00
|
|
|
return notFound();
|
|
|
|
}
|
|
|
|
|
2025-03-08 10:00:13 +00:00
|
|
|
return (
|
2025-04-04 09:03:55 +00:00
|
|
|
<div className="flex flex-col h-screen">
|
2025-03-21 16:21:51 +00:00
|
|
|
<ProblemStoreProvider
|
2025-03-20 08:12:23 +00:00
|
|
|
problemId={id}
|
2025-04-09 12:38:53 +00:00
|
|
|
problem={problem}
|
2025-03-20 08:12:23 +00:00
|
|
|
editorLanguageConfigs={editorLanguageConfigs}
|
|
|
|
languageServerConfigs={languageServerConfigs}
|
2025-04-11 09:42:52 +00:00
|
|
|
submissions={submissions}
|
2025-03-20 08:12:23 +00:00
|
|
|
>
|
|
|
|
<PlaygroundHeader />
|
|
|
|
<main className="flex flex-grow overflow-y-hidden p-2.5 pt-0">
|
2025-04-06 07:58:12 +00:00
|
|
|
{children}
|
2025-03-20 08:12:23 +00:00
|
|
|
</main>
|
2025-03-21 16:21:51 +00:00
|
|
|
</ProblemStoreProvider>
|
2025-03-08 10:00:13 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|