"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: 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 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, 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 colleges = MOCK_COLLEGES[activeTab] || [] const TAB_COLORS: Record = { Reach: "bg-purple-500/10 border-purple-500/20 text-purple-400", Target: "bg-[#00F0FF]/10 border-[#00F0FF]/20 text-[#00F0FF]", 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" && "Score +20 marks in Maths to convert IIT Roorkee from Reach to Target!"} {activeTab === "Target" && "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."}
) }