import React from 'react'; import { useRouter } from 'next/navigation'; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { CheckCircle2, XCircle, AlertCircle, Clock, Award, ArrowRight, RotateCcw, Share2, Mail } from "lucide-react"; interface ExamAttemptPayload { score: number; total_questions: number; accuracy: number; time_taken: number; answers: Array<{ question_id: string; selected_answer: string | null; is_correct: boolean; }>; } interface ExamResultProps { payload: ExamAttemptPayload; attemptId: string | null; examType?: string; // 'CBT' or 'DPS' onRetake: () => void; } export function ExamResult({ payload, attemptId, examType, onRetake }: ExamResultProps) { const router = useRouter(); const isDPP = examType === 'DPS'; const backRoute = isDPP ? '/dashboard/ai-coach/cbt-dpp' : '/dashboard/cbt'; const backLabel = isDPP ? 'Back to PrepPilot AI' : 'Back to Mock Tests'; const answered = payload.answers.filter(a => a.selected_answer !== null).length; const unanswered = payload.total_questions - answered; // Calculate correct based on score formula (+4 for correct, -1 for wrong). // Wait, payload score is just correct count according to seed script right now, let's assume it. const correctCount = payload.answers.filter(a => a.is_correct).length; const incorrectCount = answered - correctCount; // Real score calculation: +4 correct, -1 incorrect const finalScore = (correctCount * 4) - (incorrectCount * 1); const maxPossibleScore = payload.total_questions * 4; const formatTime = (seconds: number) => { const h = Math.floor(seconds / 3600); const m = Math.floor((seconds % 3600) / 60); const s = seconds % 60; if (h > 0) return `${h}h ${m}m ${s}s`; return `${m}m ${s}s`; }; return (

Exam Successfully Submitted

Here is a quick snapshot of your performance.

Final Score
{finalScore} / {maxPossibleScore}
Accuracy
{Math.round(payload.accuracy)}%
Time Taken
{formatTime(payload.time_taken)}
Attempted
{answered} / {payload.total_questions}
{correctCount}
Correct
{incorrectCount}
Incorrect
{unanswered}
Unanswered
{attemptId && ( )}

Challenge a Friend

Share this test with your friends and see if they can beat your score of {finalScore}!

); }