mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-18 15:26:33 +00:00
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:
parent
33930e7a33
commit
ad8a3e646e
21
src/features/problems/code/components/content.tsx
Normal file
21
src/features/problems/code/components/content.tsx
Normal 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 />;
|
||||||
|
};
|
25
src/features/problems/code/components/panel.tsx
Normal file
25
src/features/problems/code/components/panel.tsx
Normal 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>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user