feat: apply various dashboard and auth fixes including demo trials, settings UI, and signup options
This commit is contained in:
@@ -4,7 +4,6 @@ import { fetchWithAuth } from "@/lib/apiClient";
|
||||
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<string, Array<{ rank: number; name: string; branch: string; match: number; location: string; type: string; starred?: boolean }>> = {
|
||||
Reach: [
|
||||
@@ -56,22 +55,28 @@ const MATCH_COLOR = (match: number) => {
|
||||
export function CollegePredictorCard() {
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [activeTab, setActiveTab] = useState("Target")
|
||||
const { userId, user, loading: userLoading } = useActiveUser()
|
||||
const [isNeet, setIsNeet] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (userLoading || !userId) return
|
||||
// Read userId and target exam from localStorage to avoid SSR issues
|
||||
const userId = typeof window !== 'undefined' ? localStorage.getItem('activeUserId') : null;
|
||||
if (!userId) { setLoading(false); return; }
|
||||
|
||||
async function fetchData() {
|
||||
try {
|
||||
const res = await fetchWithAuth(`/api/ai-coach/readiness/${userId}`)
|
||||
if (!res.ok) throw new Error("fallback")
|
||||
const res = await fetchWithAuth(`/api/users/${userId}`);
|
||||
if (res.ok) {
|
||||
const userData = await res.json();
|
||||
setIsNeet(userData?.target_exam === 'NEET');
|
||||
}
|
||||
} catch {
|
||||
// Use mock data — no-op
|
||||
// Use default (JEE) on error
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
fetchData()
|
||||
}, [userId, userLoading])
|
||||
}, [])
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -81,7 +86,6 @@ export function CollegePredictorCard() {
|
||||
)
|
||||
}
|
||||
|
||||
const isNeet = user?.target_exam === "NEET";
|
||||
const colleges = (isNeet ? MOCK_COLLEGES_NEET[activeTab] : MOCK_COLLEGES_JEE[activeTab]) || []
|
||||
|
||||
const TAB_COLORS: Record<string, string> = {
|
||||
|
||||
Reference in New Issue
Block a user