feat: add AI options to landing mock sidebar and wire database-backed stats & leaderboard with fresh zero states
This commit is contained in:
@@ -5,7 +5,7 @@ import { Card, CardContent } from "@/components/ui/card"
|
||||
import { Check, RefreshCw } from "lucide-react"
|
||||
import Link from "next/link"
|
||||
|
||||
import { useActiveUser } from "@/hooks/useActiveUser"
|
||||
import { useActiveUser, isDemoUser } from "@/hooks/useActiveUser"
|
||||
|
||||
export function StudyPlanCard() {
|
||||
const [tasks, setTasks] = useState<any[]>([])
|
||||
@@ -19,7 +19,7 @@ export function StudyPlanCard() {
|
||||
try {
|
||||
const res = await fetch(`/api/ai-coach/study-plan/today?user_id=${userId}`)
|
||||
if (!res.ok) {
|
||||
// If no plan is generated yet, fallback to mock silently
|
||||
// If no plan is generated yet, fallback silently
|
||||
throw new Error("silent_fallback")
|
||||
}
|
||||
const data = await res.json()
|
||||
@@ -28,14 +28,24 @@ export function StudyPlanCard() {
|
||||
if (err.message !== "silent_fallback") {
|
||||
console.error("Study plan fetch error:", err)
|
||||
}
|
||||
// Mock fallback if celery hasn't seeded yet
|
||||
setTasks([
|
||||
{ type: "DPS", description: "Electrostatics + Kinematics", duration_minutes: 20, status: "Done" },
|
||||
{ type: "Mistake_Review", description: "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" }
|
||||
])
|
||||
if (isDemoUser(userId)) {
|
||||
// Demo user gets showcase active tasks
|
||||
setTasks([
|
||||
{ type: "DPS", description: "Electrostatics + Kinematics", duration_minutes: 20, status: "Done" },
|
||||
{ type: "Mistake_Review", description: "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" }
|
||||
])
|
||||
} else {
|
||||
// Real user gets a fresh Day 1 plan with all tasks pending
|
||||
setTasks([
|
||||
{ type: "DPS", description: "Day 1 Diagnostic Practice Sheet", duration_minutes: 20, status: "Pending" },
|
||||
{ type: "Micro_test", description: "Foundation Concept Check", duration_minutes: 15, status: "Pending" },
|
||||
{ type: "Revision", description: "Target Exam Core Topics Orientation", duration_minutes: 30, status: "Pending" },
|
||||
{ type: "Mistake_Review", description: "Initialize AI Mistake Engine", duration_minutes: 10, status: "Pending" }
|
||||
])
|
||||
}
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user