"use client" import { useEffect, useState } from "react" import { Card, CardContent } from "@/components/ui/card" import { RefreshCw, TrendingUp, MapPin, Star } from "lucide-react" import { useActiveUser } from "@/hooks/useActiveUser" const MOCK_COLLEGES_JEE: Record> = { Reach: [ { rank: 1, name: "IIT Bombay", branch: "Computer Science", match: 48, location: "Mumbai", type: "IIT", starred: true }, { rank: 2, name: "IIT Delhi", branch: "Electrical Engineering", match: 52, location: "Delhi", type: "IIT" }, { rank: 3, name: "IIT Madras", branch: "Mech. Engineering", match: 55, location: "Chennai", type: "IIT" }, { rank: 4, name: "IIT Roorkee", branch: "Computer Science", match: 60, location: "Roorkee", type: "IIT", starred: true }, { rank: 5, name: "IIT Kharagpur", branch: "Aerospace Engg.", match: 63, location: "Kharagpur", type: "IIT" }, ], Target: [ { rank: 1, name: "NIT Trichy", branch: "Computer Science", match: 85, location: "Trichy", type: "NIT", starred: true }, { rank: 2, name: "NIT Surathkal", branch: "Information Tech.", match: 78, location: "Surathkal", type: "NIT" }, { rank: 3, name: "NIT Warangal", branch: "Electronics & Comm.", match: 74, location: "Warangal", type: "NIT" }, { rank: 4, name: "BITS Pilani", branch: "Computer Science", match: 70, location: "Pilani", type: "BITS", starred: true }, { rank: 5, name: "NIT Calicut", branch: "Computer Science", match: 68, location: "Calicut", type: "NIT" }, ], Safety: [ { rank: 1, name: "IIIT Hyderabad", branch: "Computer Science", match: 94, location: "Hyderabad", type: "IIIT", starred: true }, { rank: 2, name: "IIIT Allahabad", branch: "Information Tech.", match: 91, location: "Allahabad", type: "IIIT" }, { rank: 3, name: "DTU Delhi", branch: "Software Engineering", match: 89, location: "Delhi", type: "State" }, { rank: 4, name: "NSIT Delhi", branch: "Computer Engineering", match: 87, location: "Delhi", type: "State" }, { rank: 5, name: "NIT Jamshedpur", branch: "Mech. Engineering", match: 84, location: "Jamshedpur", type: "NIT" }, ], } const MOCK_COLLEGES_NEET: Record> = { Reach: [ { rank: 1, name: "AIIMS New Delhi", branch: "MBBS", match: 48, location: "Delhi", type: "AIIMS", starred: true }, { rank: 2, name: "JIPMER", branch: "MBBS", match: 52, location: "Puducherry", type: "Govt" }, { rank: 3, name: "MAMC", branch: "MBBS", match: 55, location: "Delhi", type: "Govt" }, ], Target: [ { rank: 1, name: "KGMU", branch: "MBBS", match: 85, location: "Lucknow", type: "Govt", starred: true }, { rank: 2, name: "CMC Vellore", branch: "MBBS", match: 78, location: "Vellore", type: "Private" }, { rank: 3, name: "VMMC", branch: "MBBS", match: 74, location: "Delhi", type: "Govt" }, ], Safety: [ { rank: 1, name: "State Govt Medical College", branch: "MBBS", match: 94, location: "Local", type: "Govt", starred: true }, { rank: 2, name: "IMS BHU", branch: "BDS", match: 91, location: "Varanasi", type: "Govt" }, ], } const MATCH_COLOR = (match: number) => { if (match >= 80) return "text-green-500 bg-green-500/10" if (match >= 60) return "text-amber-500 bg-amber-500/10" return "text-red-400 bg-red-400/10" } export function CollegePredictorCard() { const [loading, setLoading] = useState(true) const [activeTab, setActiveTab] = useState("Target") const { userId, user, loading: userLoading } = useActiveUser() useEffect(() => { if (userLoading || !userId) return async function fetchData() { try { const res = await fetch(`/api/ai-coach/readiness/${userId}`) if (!res.ok) throw new Error("fallback") } catch { // Use mock data — no-op } finally { setLoading(false) } } fetchData() }, [userId, userLoading]) if (loading) { return ( ) } const isNeet = user?.target_exam === "NEET"; const colleges = (isNeet ? MOCK_COLLEGES_NEET[activeTab] : MOCK_COLLEGES_JEE[activeTab]) || [] const TAB_COLORS: Record = { Reach: "bg-purple-500/10 border-purple-500/20 text-purple-400", Target: "bg-[var(--cyan-ai-10)] border-[var(--cyan-ai-20)] text-[var(--cyan-ai)]", Safety: "bg-green-500/10 border-green-500/20 text-green-400", } const INACTIVE = "bg-white/5 border-transparent text-muted-foreground hover:bg-white/10" return ( {/* Tabs */}
{["Reach", "Target", "Safety"].map((tab) => ( ))}
{/* Tab description */}
{activeTab === "Reach" && "Colleges where your current score gives you a ~50–65% admission probability. Requires improvement."} {activeTab === "Target" && "Colleges within strong reach. Your current trajectory suggests 68–90% match probability."} {activeTab === "Safety" && "Colleges highly likely with your current score. Aim to convert all safety options."}
{/* College List */}
{colleges.map((col) => (
#{col.rank}
{col.name} {col.starred && }
{col.branch} · {col.location} · {col.type}
{col.match}%
))}
{/* Bottom Tip */}
{activeTab === "Reach" && (isNeet ? "Score +20 marks in Biology to convert AIIMS New Delhi from Reach to Target!" : "Score +20 marks in Maths to convert IIT Roorkee from Reach to Target!")} {activeTab === "Target" && (isNeet ? "Just 15 more marks in Chemistry can upgrade you from KGMU to AIIMS!" : "Just 15 more marks in Maths can upgrade you from NIT Trichy to IIT Roorkee!")} {activeTab === "Safety" && "You're on track for all safety colleges. Focus your energy on converting Target colleges."}
) }