feat(code-panel): add code editor panel components

- Add CodePanel component as container for editor interface
- Add CodeContent component with Prisma data fetching
- Include CodeContentSkeleton for loading state
- Implement ProblemEditor integration with templates
This commit is contained in:
cfngc4594 2025-05-13 16:37:35 +08:00
parent 33930e7a33
commit ad8a3e646e
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import prisma from "@/lib/prisma";
import { Loading } from "@/components/loading";
import { ProblemEditor } from "@/components/problem-editor";
interface CodeContentProps {
problemId: string;
}
export const CodeContent = async ({ problemId }: CodeContentProps) => {
const templates = await prisma.template.findMany({
where: {
problemId,
},
});
return <ProblemEditor problemId={problemId} templates={templates} />;
};
export const CodeContentSkeleton = () => {
return <Loading />;
};

View File

@ -0,0 +1,25 @@
import { Suspense } from "react";
import {
CodeContent,
CodeContentSkeleton,
} from "@/features/problems/code/components/content";
import { CodeToolbar } from "@/features/problems/code/components/toolbar/code-toolbar";
interface CodePanelProps {
problemId: string;
}
export const CodePanel = ({ problemId }: CodePanelProps) => {
return (
<div className="h-full flex flex-col border border-t-0 border-muted rounded-b-3xl bg-background overflow-hidden">
<CodeToolbar className="border-b" />
<div className="relative flex-1">
<div className="absolute h-full w-full">
<Suspense fallback={<CodeContentSkeleton />}>
<CodeContent problemId={problemId} />
</Suspense>
</div>
</div>
</div>
);
};