import { useParams, useNavigate } from "react-router-dom"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Progress } from "@/components/ui/progress"; import { Badge } from "@/components/ui/badge"; import { ArrowRight, Target, TrendingUp } from "lucide-react"; import { useProficiency } from "@/hooks/queries"; function getMasteryColor(mastery: number): string { if (mastery >= 80) return "text-green-600"; if (mastery >= 60) return "text-blue-600"; if (mastery >= 40) return "text-yellow-600"; if (mastery >= 20) return "text-orange-600"; return "text-red-600"; } function getMasteryBg(mastery: number): string { if (mastery >= 80) return "bg-green-100"; if (mastery >= 60) return "bg-blue-100"; if (mastery >= 40) return "bg-yellow-100"; if (mastery >= 20) return "bg-orange-100"; return "bg-red-100"; } export default function ProficiencyProfile() { const { subjectId } = useParams<{ subjectId: string }>(); const navigate = useNavigate(); const { data: proficiencies = [], isLoading } = useProficiency({ subject_id: Number(subjectId) }); if (isLoading) return
; const domains = [...new Set(proficiencies.map(p => p.domain_name))]; const overallMastery = proficiencies.length > 0 ? proficiencies.reduce((sum, p) => sum + p.mastery, 0) / proficiencies.length : 0; return (

Proficiency Profile

Your knowledge map across all topics.

{Math.round(overallMastery)}%

Overall Mastery

{proficiencies.filter(p => p.mastery >= 80).length}

Topics Mastered

{proficiencies.filter(p => p.mastery < 40).length}

Topics Needing Work

{domains.map((domain) => { const topics = proficiencies.filter(p => p.domain_name === domain); const domainMastery = topics.reduce((s, t) => s + t.mastery, 0) / topics.length; return (
{domain} {Math.round(domainMastery)}%
{topics.map((topic) => (
navigate(`/student/topic/${topic.topic_id}`)} >
{topic.topic_name} {Math.round(topic.mastery)}%
{topic.mastery_level}
))}
); })} {proficiencies.length === 0 && (

No proficiency data yet. Take a diagnostic assessment first.

)}
); }