"use client" import { MistakeHeatmap } from "@/components/AI/MistakeHeatmap" import { Flame, AlertTriangle, TrendingDown, BookOpen, ArrowRight, BarChart2, Target, CheckCircle2 } from "lucide-react" import { Card, CardContent } from "@/components/ui/card" import Link from "next/link" import { useActiveUser, isDemoUser } from "@/hooks/useActiveUser" const DEMO_CRITICAL_TOPICS = [ { name: "Rotational Dynamics", rate: "80%", rateNum: 80, subject: "Physics" }, { name: "Optics", rate: "60%", rateNum: 60, subject: "Physics" }, { name: "Electromagnetism", rate: "30%", rateNum: 30, subject: "Physics" }, { name: "GOC — Reaction Mechanisms", rate: "55%", rateNum: 55, subject: "Chemistry" }, { name: "Thermodynamics", rate: "25%", rateNum: 25, subject: "Physics" }, ] const DEMO_SUMMARY_STATS = [ { label: "Total Errors (Last 5 Tests)", value: "87", icon: , color: "border-red-400/20 bg-red-400/5" }, { label: "Critical Topics", value: "4", icon: , color: "border-orange-400/20 bg-orange-400/5" }, { label: "Improving Topics", value: "3", icon: , color: "border-green-400/20 bg-green-400/5" }, { label: "Avg Error Rate", value: "38%", icon: , color: "border-amber-400/20 bg-amber-400/5" }, ] const ZERO_SUMMARY_STATS = [ { label: "Total Errors (Last 5 Tests)", value: "0", icon: , color: "border-white/10 bg-white/5" }, { label: "Critical Topics", value: "0", icon: , color: "border-white/10 bg-white/5" }, { label: "Improving Topics", value: "0", icon: , color: "border-white/10 bg-white/5" }, { label: "Avg Error Rate", value: "0%", icon: , color: "border-green-400/20 bg-green-400/5" }, ] export default function HeatmapPage() { const { userId } = useActiveUser() const isDemo = isDemoUser(userId) const summaryStats = isDemo ? DEMO_SUMMARY_STATS : ZERO_SUMMARY_STATS const criticalTopics = isDemo ? DEMO_CRITICAL_TOPICS : [] return (
{/* Page Header */}

Mastery Map Vault

Visual density map of your errors across subjects and topics — pinpoint your weakest areas instantly.

Error Density Analysis
{/* KPI Strip */}
{summaryStats.map((kpi) => ( {kpi.icon}
{kpi.value}
{kpi.label}
))}
{/* Legend / Guidance Row */}
{[ { label: "Critical (> 50%)", color: "bg-red-500/20 border-red-500/30 text-red-400", dot: "bg-red-500", desc: "Immediate revision needed" }, { label: "Warning (30–50%)", color: "bg-amber-500/20 border-amber-500/30 text-amber-400", dot: "bg-amber-500", desc: "Focus on these next" }, { label: "Moderate (10–30%)", color: "bg-yellow-500/20 border-yellow-500/30 text-yellow-400", dot: "bg-yellow-500", desc: "Review periodically" }, { label: "Good (< 10%)", color: "bg-green-500/20 border-green-500/30 text-green-400", dot: "bg-green-500", desc: "Mostly understood" }, ].map((item) => (
{item.label}

{item.desc}

))}
{/* Main 2-col layout */}
{/* Heatmap — takes 2/3 */}
Topic Error Rate — Last 5 Tests
{/* Side panel */}
{/* Error frequency chart */}

Priority Topics by Error Rate

{criticalTopics.length === 0 ? (

Clean Error Log

No mistake hotspots detected yet. Practice questions to see priority areas here.

) : ( criticalTopics.map((t) => (

{t.name}

{t.subject}

= 50 ? "text-red-400 bg-red-400/10" : t.rateNum >= 30 ? "text-amber-400 bg-amber-400/10" : "text-yellow-400 bg-yellow-400/10"}`}> {t.rate}
= 50 ? "bg-red-500" : t.rateNum >= 30 ? "bg-amber-500" : "bg-yellow-500"}`} style={{ width: `${t.rateNum}%` }} />
)) )}
{/* Action card */}

What To Do Next

{[ { label: "Take a Physics DPP", href: "/dashboard/ai-coach/cbt-dpp" }, { label: "Check Exam Readiness Score", href: "/dashboard/ai-coach/readiness" }, ].map((link) => ( {link.label} ))}
{/* Tip */}

Pro Tip: Focus the next 3 days entirely on Rotational Dynamics — it alone is worth 8–12 marks in JEE and shows an 80% error rate across your last 5 tests.

) }