"use client" import { useEffect, useState } from "react" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { GraduationCap, MapPin, RefreshCw } from "lucide-react" import { useActiveUser } from "@/hooks/useActiveUser" export function CollegePredictorCard() { const [data, setData] = useState(null) const [loading, setLoading] = useState(true) const { userId, loading: userLoading } = useActiveUser(); useEffect(() => { if (userLoading || !userId) return; async function fetchReadiness() { try { const res = await fetch(`/api/ai-coach/readiness/${userId}`) if (!res.ok) throw new Error("Failed to fetch") const json = await res.json() setData(json) } catch (err) { console.warn("Using mock fallback data for College Predictor.") setData({ college_prediction: "NIT Trichy / NIT Surathkal on track.", prediction_category: "Target" }) } finally { setLoading(false) } } fetchReadiness() }, [userId, userLoading]) if (loading) { return ( ) } const prediction = data?.college_prediction || "Keep Practicing" const category = data?.prediction_category || "State Level" const getCategoryColor = (cat: string) => { switch(cat.toUpperCase()) { case "REACH": return "bg-purple-500/10 text-purple-600 border-purple-500/20" case "TARGET": return "bg-blue-500/10 text-blue-600 border-blue-500/20" case "SAFETY": return "bg-green-500/10 text-green-600 border-green-500/20" default: return "bg-secondary text-muted-foreground border-transparent" } } return (
Admissions Radar
{category}
AI-projected admission trajectory.

"{prediction}"

Prediction updates dynamically after every test.

) }