import type { ReactNode } from "react"; import { useParams, useNavigate } from "react-router-dom"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Progress } from "@/components/ui/progress"; import { Badge } from "@/components/ui/badge"; import { Loader2, Lock, CheckCircle2, PlayCircle, Circle, ArrowRight, Sparkles } from "lucide-react"; import { useLearningPlan, useGenerateLearningPlan } from "@/hooks/queries"; import { useToast } from "@/hooks/use-toast"; import type { PlanItemStatus } from "@/types"; const statusIcons: Record = { locked: , available: , in_progress: , completed: , }; const statusColors: Record = { locked: "bg-muted text-muted-foreground", available: "bg-blue-50 text-blue-700 border-blue-200", in_progress: "bg-yellow-50 text-yellow-700 border-yellow-200", completed: "bg-green-50 text-green-700 border-green-200", }; export default function LearningPlanPage() { const { subjectId } = useParams<{ subjectId: string }>(); const navigate = useNavigate(); const { toast } = useToast(); const { data: plan, isLoading } = useLearningPlan({ subject_id: Number(subjectId) }); const generateMutation = useGenerateLearningPlan(); const handleGenerate = () => { generateMutation.mutate( { subject_id: Number(subjectId) }, { onSuccess: () => toast({ title: "Plan Generated", description: "Your personalized learning plan is ready." }), onError: () => toast({ title: "Error", description: "Failed to generate plan", variant: "destructive" }), } ); }; if (isLoading) return
; if (!plan) { return (

No Learning Plan Yet

Complete a diagnostic assessment first, then generate your personalized learning plan.

); } const items = plan.items.sort((a, b) => a.sequence - b.sequence); return (

Learning Plan: {plan.subject_name}

{plan.ai_summary}

{plan.status}
Overall Progress {Math.round(plan.overall_progress)}%
{items.map((item, index) => (
{index + 1}
{statusIcons[item.status]}
{item.topic_name} {item.domain_name}
~{item.estimated_hours}h estimated {item.actual_hours > 0 && {item.actual_hours}h spent} Mastery: {Math.round(item.mastery)}%
{item.status !== "locked" && ( )}
{(item.status === "available" || item.status === "in_progress") && ( )} {item.status === "completed" && ( )}
))}
); }