mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
refactor(page): simplify WorkspaceEditorPage by removing unnecessary database queries and state management
This commit is contained in:
parent
ceee810e14
commit
d79b88e0b6
@ -1,50 +1,15 @@
|
|||||||
import prisma from "@/lib/prisma";
|
|
||||||
import { notFound } from "next/navigation";
|
|
||||||
import { CodeEditor } from "@/components/problem-editor";
|
import { CodeEditor } from "@/components/problem-editor";
|
||||||
import { ProblemEditorProvider } from "@/providers/problem-editor-provider";
|
|
||||||
import { WorkspaceEditorHeader } from "@/components/features/playground/workspace/editor/components/header";
|
import { WorkspaceEditorHeader } from "@/components/features/playground/workspace/editor/components/header";
|
||||||
import { WorkspaceEditorFooter } from "@/components/features/playground/workspace/editor/components/footer";
|
import { WorkspaceEditorFooter } from "@/components/features/playground/workspace/editor/components/footer";
|
||||||
|
|
||||||
interface WorkspaceEditorProps {
|
export default function WorkspaceEditorPage() {
|
||||||
params: Promise<{ id: string }>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default async function WorkspaceEditorPage({
|
|
||||||
params,
|
|
||||||
}: WorkspaceEditorProps) {
|
|
||||||
const { id } = await params;
|
|
||||||
|
|
||||||
const [
|
|
||||||
problem,
|
|
||||||
editorLanguageConfigs,
|
|
||||||
languageServerConfigs,
|
|
||||||
] = await Promise.all([
|
|
||||||
prisma.problem.findUnique({
|
|
||||||
where: { id },
|
|
||||||
select: { templates: true },
|
|
||||||
}),
|
|
||||||
prisma.editorLanguageConfig.findMany(),
|
|
||||||
prisma.languageServerConfig.findMany(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (!problem) {
|
|
||||||
return notFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ProblemEditorProvider
|
<>
|
||||||
problemId={id}
|
<WorkspaceEditorHeader />
|
||||||
templates={problem.templates ?? []}
|
<div className="flex-1">
|
||||||
editorLanguageConfigs={editorLanguageConfigs}
|
<CodeEditor />
|
||||||
languageServerConfigs={languageServerConfigs}
|
</div>
|
||||||
>
|
<WorkspaceEditorFooter />
|
||||||
<>
|
</>
|
||||||
<WorkspaceEditorHeader />
|
|
||||||
<div className="flex-1">
|
|
||||||
<CodeEditor />
|
|
||||||
</div>
|
|
||||||
<WorkspaceEditorFooter />
|
|
||||||
</>
|
|
||||||
</ProblemEditorProvider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user