From f6fc01ae6a07a27528065b09206281a61f106991 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Sun, 9 Mar 2025 11:06:10 +0800 Subject: [PATCH] feat(workspace): fetch problem templates and pass to editor header --- .../[id]/@workspace/@editor/layout.tsx | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/app/(app)/problems/[id]/@workspace/@editor/layout.tsx b/src/app/(app)/problems/[id]/@workspace/@editor/layout.tsx index abbe23c..f2f3f35 100644 --- a/src/app/(app)/problems/[id]/@workspace/@editor/layout.tsx +++ b/src/app/(app)/problems/[id]/@workspace/@editor/layout.tsx @@ -1,16 +1,35 @@ +import prisma from "@/lib/prisma"; import WorkspaceEditorHeader from "@/features/playground/workspace/editor/header"; import WorkspaceEditorFooter from "@/features/playground/workspace/editor/footer"; interface WorkspaceEditorLayoutProps { + params: Promise<{ id: string }>; children: React.ReactNode; } -export default function WorkspaceEditorLayout({ +export default async function WorkspaceEditorLayout({ + params, children, }: WorkspaceEditorLayoutProps) { + const { id } = await params; + + const problem = await prisma.problem.findUnique({ + where: { id: parseInt(id) }, + select: { + templates: { + select: { + language: true, + template: true, + } + } + } + }); + + const templates = problem?.templates ?? []; + return (
- +
{children}