2025-03-20 08:12:23 +00:00
|
|
|
import prisma from "@/lib/prisma";
|
2025-03-21 16:21:51 +00:00
|
|
|
import {
|
|
|
|
ResizableHandle,
|
|
|
|
ResizablePanel,
|
|
|
|
ResizablePanelGroup,
|
|
|
|
} from "@/components/ui/resizable";
|
2025-03-20 08:12:23 +00:00
|
|
|
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-03-08 13:11:18 +00:00
|
|
|
interface PlaygroundLayoutProps {
|
2025-03-20 08:12:23 +00:00
|
|
|
params: Promise<{ id: string }>;
|
2025-03-08 10:00:13 +00:00
|
|
|
problem: React.ReactNode;
|
2025-03-08 13:11:18 +00:00
|
|
|
workspace: React.ReactNode;
|
2025-03-08 10:00:13 +00:00
|
|
|
terminal: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
2025-03-20 08:12:23 +00:00
|
|
|
export default async function PlaygroundLayout({
|
|
|
|
params,
|
2025-03-08 10:00:13 +00:00
|
|
|
problem,
|
2025-03-08 13:11:18 +00:00
|
|
|
workspace,
|
2025-03-08 10:00:13 +00:00
|
|
|
terminal,
|
2025-03-08 13:11:18 +00:00
|
|
|
}: PlaygroundLayoutProps) {
|
2025-03-20 08:12:23 +00:00
|
|
|
const { id } = await params;
|
|
|
|
|
|
|
|
const [
|
|
|
|
problemData,
|
|
|
|
editorLanguageConfigs,
|
|
|
|
languageServerConfigs,
|
|
|
|
] = await Promise.all([
|
|
|
|
prisma.problem.findUnique({
|
|
|
|
where: { id },
|
2025-03-24 02:32:20 +00:00
|
|
|
include: { templates: true },
|
2025-03-20 08:12:23 +00:00
|
|
|
}),
|
|
|
|
prisma.editorLanguageConfig.findMany(),
|
|
|
|
prisma.languageServerConfig.findMany(),
|
|
|
|
]);
|
|
|
|
|
|
|
|
if (!problemData) {
|
|
|
|
return notFound();
|
|
|
|
}
|
|
|
|
|
2025-03-24 02:39:56 +00:00
|
|
|
const { templates, ...problemWithoutTemplates } = problemData;
|
|
|
|
|
2025-03-08 10:00:13 +00:00
|
|
|
return (
|
|
|
|
<div className="h-screen flex flex-col">
|
2025-03-21 16:21:51 +00:00
|
|
|
<ProblemStoreProvider
|
2025-03-20 08:12:23 +00:00
|
|
|
problemId={id}
|
2025-03-24 02:39:56 +00:00
|
|
|
problem={problemWithoutTemplates}
|
|
|
|
templates={templates}
|
2025-03-20 08:12:23 +00:00
|
|
|
editorLanguageConfigs={editorLanguageConfigs}
|
|
|
|
languageServerConfigs={languageServerConfigs}
|
|
|
|
>
|
|
|
|
<PlaygroundHeader />
|
|
|
|
<main className="flex flex-grow overflow-y-hidden p-2.5 pt-0">
|
|
|
|
<ResizablePanelGroup direction="horizontal" className="relative h-full flex">
|
|
|
|
<ResizablePanel defaultSize={50} className="border border-muted rounded-xl min-w-9">
|
|
|
|
{problem}
|
|
|
|
</ResizablePanel>
|
|
|
|
<ResizableHandle className="mx-1 bg-transparent hover:bg-blue-500" />
|
|
|
|
<ResizablePanel defaultSize={50} className="min-w-9">
|
|
|
|
<ResizablePanelGroup direction="vertical">
|
|
|
|
<ResizablePanel defaultSize={50} className="border border-muted rounded-xl min-h-9">
|
|
|
|
{workspace}
|
|
|
|
</ResizablePanel>
|
|
|
|
<ResizableHandle className="my-1 bg-transparent hover:bg-blue-500" />
|
|
|
|
<ResizablePanel defaultSize={50} className="border border-muted rounded-xl min-h-9">
|
|
|
|
{terminal}
|
|
|
|
</ResizablePanel>
|
|
|
|
</ResizablePanelGroup>
|
|
|
|
</ResizablePanel>
|
|
|
|
</ResizablePanelGroup>
|
|
|
|
</main>
|
2025-03-21 16:21:51 +00:00
|
|
|
</ProblemStoreProvider>
|
2025-03-08 10:00:13 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2025-03-24 03:27:40 +00:00
|
|
|
|
|
|
|
export async function generateStaticParams() {
|
|
|
|
const problems = await prisma.problem.findMany({
|
|
|
|
select: { id: true },
|
|
|
|
});
|
|
|
|
|
|
|
|
return problems.map((problem) => ({
|
|
|
|
id: problem.id,
|
|
|
|
}));
|
|
|
|
}
|