mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 07:16:34 +00:00
refactor(editor): integrate ProblemEditorProvider for workspace editor
This commit is contained in:
parent
fae504b35d
commit
783b8415ea
@ -1,6 +1,7 @@
|
|||||||
import prisma from "@/lib/prisma";
|
import prisma from "@/lib/prisma";
|
||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation";
|
||||||
import CodeEditor from "@/components/code-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";
|
||||||
|
|
||||||
@ -13,17 +14,14 @@ export default async function WorkspaceEditorPage({
|
|||||||
}: WorkspaceEditorProps) {
|
}: WorkspaceEditorProps) {
|
||||||
const { id } = await params;
|
const { id } = await params;
|
||||||
|
|
||||||
const [problem, editorLanguageConfigs, languageServerConfigs] = await Promise.all([
|
const [
|
||||||
|
problem,
|
||||||
|
editorLanguageConfigs,
|
||||||
|
languageServerConfigs,
|
||||||
|
] = await Promise.all([
|
||||||
prisma.problem.findUnique({
|
prisma.problem.findUnique({
|
||||||
where: { id },
|
where: { id },
|
||||||
select: {
|
select: { templates: true },
|
||||||
templates: {
|
|
||||||
select: {
|
|
||||||
language: true,
|
|
||||||
template: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
prisma.editorLanguageConfig.findMany(),
|
prisma.editorLanguageConfig.findMany(),
|
||||||
prisma.languageServerConfig.findMany(),
|
prisma.languageServerConfig.findMany(),
|
||||||
@ -33,19 +31,20 @@ export default async function WorkspaceEditorPage({
|
|||||||
return notFound();
|
return notFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
const commonProps = {
|
|
||||||
templates: problem.templates ?? [],
|
|
||||||
editorLanguageConfigs,
|
|
||||||
languageServerConfigs,
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<ProblemEditorProvider
|
||||||
|
problemId={id}
|
||||||
|
templates={problem.templates ?? []}
|
||||||
|
editorLanguageConfigs={editorLanguageConfigs}
|
||||||
|
languageServerConfigs={languageServerConfigs}
|
||||||
|
>
|
||||||
<>
|
<>
|
||||||
<WorkspaceEditorHeader {...commonProps} />
|
<WorkspaceEditorHeader />
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<CodeEditor problemId={id} {...commonProps} />
|
<CodeEditor />
|
||||||
</div>
|
</div>
|
||||||
<WorkspaceEditorFooter />
|
<WorkspaceEditorFooter />
|
||||||
</>
|
</>
|
||||||
|
</ProblemEditorProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user