"use client" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { BrainCircuit, Play, CheckCircle2, Download, Filter, Lock } from "lucide-react" import { useEffect, useState } from "react" import Link from "next/link" import { useActiveUser } from "@/hooks/useActiveUser" export default function DPPPage() { const { user } = useActiveUser() const [dpps, setDpps] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { async function fetchDpps() { if (!user) return; // Wait for user to be available try { const pattern = user.target_exam || "JEE_Main"; // Also fetch from the correct Next.js proxied route instead of localhost:8000 const res = await fetch(`/api/tests?type=DPS&exam_pattern=${pattern}`); if (res.ok) { const data = await res.json() setDpps(data) } } catch (err) { console.error("Failed to fetch DPPs", err) } finally { setLoading(false) } } fetchDpps() }, [user]) const getDifficultyColor = (diff: string) => { switch(diff) { case 'Easy': return 'text-emerald-500 bg-emerald-500/10 border-emerald-500/20'; case 'Medium': return 'text-amber-500 bg-amber-500/10 border-amber-500/20'; case 'Hard': return 'text-destructive bg-destructive/10 border-destructive/20'; default: return 'text-primary bg-primary/10 border-primary/20'; } } return (

Daily Practice Problems (DPP)

Hyper-personalized problem sets generated daily by our AI Evaluator to target your specific weak areas based on past exam performance.

Difficulty: {['Mixed', 'Easy', 'Medium', 'Hard'].map((diff) => ( ))}
Pro
{loading ? (
Loading AI-generated DPPs...
) : dpps.length === 0 ? (
No DPPs available yet. Upload some PDFs in the Admin Panel!
) : dpps.map((dpp, i) => { // Calculate total questions dynamically from sections let count = 0; if (dpp.sections) { Object.values(dpp.sections).forEach((s: any) => { count += (s.questions?.length || 0) }); } // Temporary mock for status let status: string = "Pending" return (
{status === 'Completed' ? :
}
{user?.target_exam?.replace("_", " ") || "JEE/NEET"} • {dpp.difficulty} Level

{dpp.title} {dpp.difficulty}

{count} Questions • {dpp.total_time} mins
{status === 'Completed' ? ( ) : ( )}
)})}
) }