diff --git a/src/features/problems/analysis/components/content.tsx b/src/features/problems/analysis/components/content.tsx new file mode 100644 index 0000000..7ccd876 --- /dev/null +++ b/src/features/problems/analysis/components/content.tsx @@ -0,0 +1,114 @@ +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, + CardFooter, +} from "@/components/ui/card"; +import prisma from "@/lib/prisma"; +import { + ChartDataPoint, + CodeAnalysisRadarChart, +} from "@/features/problems/analysis/components/radar-chart"; + +interface AnalysisContentProps { + submissionId: string | undefined; +} + +export const AnalysisContent = async ({ submissionId }: AnalysisContentProps) => { + if (!submissionId) { + return ( +
+ No submission ID provided. +
+ ); + } + + const codeAnalysisData = await prisma.codeAnalysis.findUnique({ + where: { + submissionId: submissionId, + }, + }); + + if (!codeAnalysisData) { + return ( +
+ No analysis data found for this submission. +
+ ); + } + + // Transform the data into a format suitable for the RadarChart + const chartData: ChartDataPoint[] = [ + { + kind: "overall", + score: codeAnalysisData.overallScore ?? 0, + fullMark: 100, + }, + { + kind: "style", + score: codeAnalysisData.styleScore ?? 0, + fullMark: 100, + }, + { + kind: "readability", + score: codeAnalysisData.readabilityScore ?? 0, + fullMark: 100, + }, + { + kind: "efficiency", + score: codeAnalysisData.efficiencyScore ?? 0, + fullMark: 100, + }, + { + kind: "correctness", + score: codeAnalysisData.correctnessScore ?? 0, + fullMark: 100, + }, + ]; + + return ( + + + + Code Analysis + + + Detailed evaluation of your code submission + + + + + + + +
+
+ Overall Score + + {codeAnalysisData.overallScore ?? "N/A"} + /100 + +
+
+
+
+
+ +
+

Feedback

+

+ {codeAnalysisData.feedback} +

+
+ + + ); +}; diff --git a/src/features/problems/detail/components/content.tsx b/src/features/problems/detail/components/content.tsx index 9a94310..0176b54 100644 --- a/src/features/problems/detail/components/content.tsx +++ b/src/features/problems/detail/components/content.tsx @@ -1,6 +1,7 @@ import { Skeleton } from "@/components/ui/skeleton"; import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area"; import { DetailTable } from "@/features/problems/detail/components/table"; +import { AnalysisContent } from "@/features/problems/analysis/components/content"; interface DetailContentProps { submissionId: string; @@ -10,6 +11,7 @@ export const DetailContent = ({ submissionId }: DetailContentProps) => { return ( + );