"use client" import { useState, useEffect } from "react" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { ChevronDown, ChevronRight, CheckCircle2, Circle, Clock, Activity, BarChart3 } from "lucide-react" import { useActiveUser, isDemoUser } from "@/hooks/useActiveUser" import { PremiumGate } from "@/components/PremiumGate" type ChapterStatus = 'Mastered' | 'Practiced' | 'In Progress' | 'Not Started' interface Topic { name: string status: ChapterStatus accuracy: number questionsAttempted: number } interface Chapter { name: string topics: Topic[] isExpanded: boolean } interface Subject { name: string chapters: Chapter[] completionPct: number } const getStatusIcon = (status: ChapterStatus) => { switch (status) { case 'Mastered': return case 'Practiced': return case 'In Progress': return case 'Not Started': return } } const DEMO_SUBJECTS: Subject[] = [ { name: "Physics", completionPct: 42, chapters: [ { name: "Kinematics", isExpanded: true, topics: [ { name: "Motion in One Dimension", status: "Mastered", accuracy: 92, questionsAttempted: 150 }, { name: "Projectile Motion", status: "Practiced", accuracy: 75, questionsAttempted: 85 }, { name: "Relative Velocity", status: "In Progress", accuracy: 45, questionsAttempted: 20 }, ] }, { name: "Laws of Motion", isExpanded: false, topics: [ { name: "Newton's First Law", status: "Practiced", accuracy: 88, questionsAttempted: 40 }, { name: "Friction", status: "In Progress", accuracy: 50, questionsAttempted: 35 }, ] }, { name: "Thermodynamics", isExpanded: false, topics: [ { name: "First Law", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Carnot Engine", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] } ] }, { name: "Chemistry", completionPct: 68, chapters: [ { name: "Atomic Structure", isExpanded: false, topics: [ { name: "Bohr Model", status: "Mastered", accuracy: 95, questionsAttempted: 110 }, { name: "Quantum Numbers", status: "Mastered", accuracy: 88, questionsAttempted: 95 }, ] } ] }, // Math/Bio dynamic subjects handled below ] const ZERO_SUBJECTS: Subject[] = [ { name: "Physics", completionPct: 0, chapters: [ { name: "Kinematics", isExpanded: true, topics: [ { name: "Motion in One Dimension", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Projectile Motion", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Relative Velocity", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] }, { name: "Laws of Motion", isExpanded: false, topics: [ { name: "Newton's First Law", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Friction", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] }, { name: "Thermodynamics", isExpanded: false, topics: [ { name: "First Law", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Carnot Engine", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] } ] }, { name: "Chemistry", completionPct: 0, chapters: [ { name: "Atomic Structure", isExpanded: false, topics: [ { name: "Bohr Model", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Quantum Numbers", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] } ] }, // Math/Bio dynamic subjects handled below ] export default function ProgressTrackerPage() { const { userId, user } = useActiveUser() const isDemo = isDemoUser(userId) const [subjects, setSubjects] = useState([]) useEffect(() => { const targetExam = user?.target_exam || "JEE_Main"; const isNeet = targetExam === "NEET"; const isJeeNeet = targetExam === "JEE_NEET"; const mathDemoSubject: Subject = { name: "Mathematics", completionPct: 28, chapters: [ { name: "Calculus", isExpanded: true, topics: [ { name: "Limits", status: "In Progress", accuracy: 60, questionsAttempted: 45 }, { name: "Derivatives", status: "Practiced", accuracy: 72, questionsAttempted: 35 }, { name: "Integrals", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] }, { name: "Coordinate Geometry", isExpanded: false, topics: [ { name: "Straight Lines", status: "Practiced", accuracy: 80, questionsAttempted: 40 }, { name: "Circles", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] } ] }; const bioDemoSubject: Subject = { name: "Biology", completionPct: 35, chapters: [ { name: "Cell Structure", isExpanded: true, topics: [ { name: "Cell Wall", status: "Practiced", accuracy: 80, questionsAttempted: 60 }, { name: "Nucleus", status: "In Progress", accuracy: 50, questionsAttempted: 25 }, ] }, { name: "Genetics & Evolution", isExpanded: false, topics: [ { name: "Mendelian Genetics", status: "Practiced", accuracy: 85, questionsAttempted: 55 }, { name: "Molecular Basis of Inheritance", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] } ] }; const mathZeroSubject: Subject = { name: "Mathematics", completionPct: 0, chapters: [ { name: "Calculus", isExpanded: true, topics: [ { name: "Limits", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Derivatives", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Integrals", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] }, { name: "Coordinate Geometry", isExpanded: false, topics: [ { name: "Straight Lines", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Circles", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] } ] }; const bioZeroSubject: Subject = { name: "Biology", completionPct: 0, chapters: [ { name: "Cell Structure", isExpanded: true, topics: [ { name: "Cell Wall", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Nucleus", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] }, { name: "Genetics & Evolution", isExpanded: false, topics: [ { name: "Mendelian Genetics", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, { name: "Molecular Basis of Inheritance", status: "Not Started", accuracy: 0, questionsAttempted: 0 }, ] } ] }; const base = isDemo ? [...DEMO_SUBJECTS] : [...ZERO_SUBJECTS]; if (isJeeNeet) { // 4 Subjects for JEE + NEET: Physics, Chemistry, Mathematics, Biology base.push(isDemo ? mathDemoSubject : mathZeroSubject); base.push(isDemo ? bioDemoSubject : bioZeroSubject); } else if (isNeet) { base.push(isDemo ? bioDemoSubject : bioZeroSubject); } else { base.push(isDemo ? mathDemoSubject : mathZeroSubject); } setSubjects(base); }, [isDemo, user?.target_exam]); const toggleChapter = (subjectIndex: number, chapterIndex: number) => { const newSubjects = [...subjects] newSubjects[subjectIndex].chapters[chapterIndex].isExpanded = !newSubjects[subjectIndex].chapters[chapterIndex].isExpanded setSubjects(newSubjects) } return ( Syllabus Tracker Track your syllabus coverage and mastery per chapter to ensure no gaps. = 4 ? 'lg:grid-cols-4' : 'md:grid-cols-3'} gap-6 mb-8 animate-section animate-section-2`}> {subjects.map((sub, i) => ( {sub.name} {sub.completionPct}% ))} {subjects.map((subject, subIndex) => ( {subject.name} Syllabus {subject.chapters.map((chapter, chapIndex) => ( toggleChapter(subIndex, chapIndex)} className="flex items-center justify-between p-4 hover:bg-secondary/20 transition-colors text-left" > {chapter.isExpanded ? : } {chapter.name} {chapter.topics.length} Topics {chapter.isExpanded && ( TOPIC ACCURACY QUESTIONS {chapter.topics.map((topic, topIndex) => ( {getStatusIcon(topic.status)} {topic.name} {topic.status} {topic.accuracy > 0 ? ( 80 ? 'text-emerald-500' : topic.accuracy > 60 ? 'text-amber-500' : 'text-red-500'}`}> {topic.accuracy}% ) : -} {topic.questionsAttempted > 0 ? topic.questionsAttempted : '-'} ))} )} ))} ))} ) }
Track your syllabus coverage and mastery per chapter to ensure no gaps.
{topic.name}
{topic.status}