feat: complete comprehensive zero-state metrics across all dashboard pages for new accounts

This commit is contained in:
2026-09-13 22:17:40 +05:30
parent d9bd142e6a
commit afab06d33c
22 changed files with 771 additions and 299 deletions

View File

@@ -1,8 +1,9 @@
"use client"
import { useState } from "react"
import { useState, useEffect } from "react"
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"
import { ChevronDown, ChevronRight, CheckCircle2, Circle, Clock, Activity, Target } from "lucide-react"
import { useActiveUser, isDemoUser } from "@/hooks/useActiveUser"
type ChapterStatus = 'Mastered' | 'Practiced' | 'In Progress' | 'Not Started'
@@ -34,68 +35,138 @@ const getStatusIcon = (status: ChapterStatus) => {
}
}
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 },
]
}
]
},
{
name: "Mathematics / Biology",
completionPct: 22,
chapters: [
{
name: "Calculus",
isExpanded: false,
topics: [
{ name: "Limits", status: "In Progress", accuracy: 60, questionsAttempted: 45 },
{ name: "Derivatives", status: "Not Started", accuracy: 0, questionsAttempted: 0 },
]
}
]
}
]
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 },
]
}
]
},
{
name: "Mathematics / Biology",
completionPct: 0,
chapters: [
{
name: "Core Foundation",
isExpanded: false,
topics: [
{ name: "Limits / Cell Structure", status: "Not Started", accuracy: 0, questionsAttempted: 0 },
{ name: "Derivatives / Genetics", status: "Not Started", accuracy: 0, questionsAttempted: 0 },
]
}
]
}
]
export default function ProgressTrackerPage() {
const [subjects, setSubjects] = useState<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 },
]
}
]
},
{
name: "Mathematics",
completionPct: 22,
chapters: [
{
name: "Calculus",
isExpanded: false,
topics: [
{ name: "Limits", status: "In Progress", accuracy: 60, questionsAttempted: 45 },
{ name: "Derivatives", status: "Not Started", accuracy: 0, questionsAttempted: 0 },
]
}
]
}
])
const { userId } = useActiveUser()
const isDemo = isDemoUser(userId)
const [subjects, setSubjects] = useState<Subject[]>(isDemo ? DEMO_SUBJECTS : ZERO_SUBJECTS)
useEffect(() => {
setSubjects(isDemo ? DEMO_SUBJECTS : ZERO_SUBJECTS)
}, [isDemo])
const toggleChapter = (subjectIndex: number, chapterIndex: number) => {
const newSubjects = [...subjects]