Update AI coach calibration, fix streak animation speed, add dashboard features and target filtering

This commit is contained in:
2026-09-21 12:03:37 +05:30
parent ddde053b51
commit 63ab119f7c
11 changed files with 90 additions and 39 deletions

View File

@@ -1,11 +1,11 @@
"use client"
"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<string, Array<{ rank: number; name: string; branch: string; match: number; location: string; type: string; starred?: boolean }>> = {
const MOCK_COLLEGES_JEE: Record<string, Array<{ rank: number; name: string; branch: string; match: number; location: string; type: string; starred?: boolean }>> = {
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" },
@@ -29,6 +29,23 @@ const MOCK_COLLEGES: Record<string, Array<{ rank: number; name: string; branch:
],
}
const MOCK_COLLEGES_NEET: Record<string, Array<{ rank: number; name: string; branch: string; match: number; location: string; type: string; starred?: boolean }>> = {
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"
@@ -38,7 +55,7 @@ const MATCH_COLOR = (match: number) => {
export function CollegePredictorCard() {
const [loading, setLoading] = useState(true)
const [activeTab, setActiveTab] = useState("Target")
const { userId, loading: userLoading } = useActiveUser()
const { userId, user, loading: userLoading } = useActiveUser()
useEffect(() => {
if (userLoading || !userId) return
@@ -63,7 +80,8 @@ export function CollegePredictorCard() {
)
}
const colleges = MOCK_COLLEGES[activeTab] || []
const isNeet = user?.target_exam === "NEET";
const colleges = (isNeet ? MOCK_COLLEGES_NEET[activeTab] : MOCK_COLLEGES_JEE[activeTab]) || []
const TAB_COLORS: Record<string, string> = {
Reach: "bg-purple-500/10 border-purple-500/20 text-purple-400",
@@ -128,8 +146,8 @@ export function CollegePredictorCard() {
{/* Bottom Tip */}
<div className="mt-1 p-3 bg-yellow-500/10 border border-yellow-500/20 rounded-xl text-xs text-yellow-500 font-bold flex items-center gap-2">
<TrendingUp size={14} className="shrink-0" />
{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 === "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."}
</div>
</CardContent>

View File

@@ -1,4 +1,4 @@
"use client"
"use client"
import { useEffect, useState } from "react"
import { Card, CardContent } from "@/components/ui/card"
@@ -10,7 +10,7 @@ import { useActiveUser, isDemoUser } from "@/hooks/useActiveUser"
export function StudyPlanCard() {
const [tasks, setTasks] = useState<any[]>([])
const [loading, setLoading] = useState(true)
const { userId, loading: userLoading } = useActiveUser();
const { userId, user, loading: userLoading } = useActiveUser();
useEffect(() => {
if (userLoading || !userId) return;
@@ -30,12 +30,13 @@ export function StudyPlanCard() {
}
if (isDemoUser(userId)) {
// Demo user gets showcase active tasks
const isNeet = user?.target_exam === "NEET";
setTasks([
{ type: "DPS", description: "Electrostatics + Kinematics", duration_minutes: 20, status: "Done" },
{ type: "Mistake_Review", description: "Thermodynamics error queue", duration_minutes: 10, status: "Done" },
{ type: "DPS", description: isNeet ? "Genetics + Evolution" : "Electrostatics + Kinematics", duration_minutes: 20, status: "Done" },
{ type: "Mistake_Review", description: isNeet ? "Human Physiology error queue" : "Thermodynamics error queue", duration_minutes: 10, status: "Done" },
{ type: "Micro_test", description: "GOC — General Organic Chemistry", duration_minutes: 5, status: "Pending" },
{ type: "Test", description: "Weekly Full-Syllabus Mock Test", duration_minutes: 180, status: "Pending" },
{ type: "Revision", description: "Circles + Straight Lines (Maths)", duration_minutes: 15, status: "Pending" }
{ type: "Revision", description: isNeet ? "Plant Anatomy (Biology)" : "Circles + Straight Lines (Maths)", duration_minutes: 15, status: "Pending" }
])
} else {
// Real user gets a fresh Day 1 plan with all tasks pending

View File

@@ -28,10 +28,9 @@ export function StreakOnboardingModal() {
// 1. Observe HTML class mutations (for immediate theme change detection)
const observer = new MutationObserver(() => {
const newTheme = checkTheme();
setCurrentTheme(newTheme);
// Re-trigger streak celebration whenever theme transitions on dashboard
setIsOpen(true);
setRenderCount((c) => c + 1);
if (newTheme !== currentTheme) {
setCurrentTheme(newTheme);
}
});
observer.observe(document.documentElement, {
@@ -43,8 +42,6 @@ export function StreakOnboardingModal() {
const handleThemeSwitched = (e: any) => {
const t = e.detail?.theme || checkTheme();
setCurrentTheme(t);
setIsOpen(true);
setRenderCount((c) => c + 1);
};
window.addEventListener("pragativeer-theme-switched", handleThemeSwitched);
@@ -80,9 +77,8 @@ export function StreakOnboardingModal() {
// Show popup if:
// 1. User account switched (demo plans: Neha, Rahul, Priya, Amit)
// 2. First time user visits (not yet dismissed in session)
// 3. User is on a demo account
const hasSeen = sessionStorage.getItem(`hasSeenStreakPopup_${user.id}`);
if (isDifferentUser || !hasSeen || isDemoUser(user.id)) {
if (isDifferentUser || !hasSeen) {
setIsOpen(true);
}
}, [user, loading]);