mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-17 23:12:23 +00:00
refactor(page): simplify WorkspaceEditorPage by removing unnecessary database queries and state management
This commit is contained in:
parent
ceee810e14
commit
d79b88e0b6
@ -1,43 +1,9 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { notFound } from "next/navigation";
|
||||
import { CodeEditor } from "@/components/problem-editor";
|
||||
import { ProblemEditorProvider } from "@/providers/problem-editor-provider";
|
||||
import { WorkspaceEditorHeader } from "@/components/features/playground/workspace/editor/components/header";
|
||||
import { WorkspaceEditorFooter } from "@/components/features/playground/workspace/editor/components/footer";
|
||||
|
||||
interface WorkspaceEditorProps {
|
||||
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();
|
||||
}
|
||||
|
||||
export default function WorkspaceEditorPage() {
|
||||
return (
|
||||
<ProblemEditorProvider
|
||||
problemId={id}
|
||||
templates={problem.templates ?? []}
|
||||
editorLanguageConfigs={editorLanguageConfigs}
|
||||
languageServerConfigs={languageServerConfigs}
|
||||
>
|
||||
<>
|
||||
<WorkspaceEditorHeader />
|
||||
<div className="flex-1">
|
||||
@ -45,6 +11,5 @@ export default async function WorkspaceEditorPage({
|
||||
</div>
|
||||
<WorkspaceEditorFooter />
|
||||
</>
|
||||
</ProblemEditorProvider>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user