diff --git a/backend/models.py b/backend/models.py index b9879d8..c5b5c41 100644 --- a/backend/models.py +++ b/backend/models.py @@ -146,7 +146,7 @@ class Attempt(SQLModel, table=True): started_at: datetime submitted_at: Optional[datetime] = None time_taken: Optional[int] = None # in seconds - answers: Optional[Dict[str, Any]] = Field(default=None, sa_type=JSON) # Array of {question_id, selected_answer, is_correct, time_spent} + answers: Optional[List[Dict[str, Any]]] = Field(default=None, sa_type=JSON) # Array of {question_id, selected_answer, is_correct, time_spent} score: int = Field(default=0) total_questions: int accuracy: float = Field(default=0.0) @@ -171,7 +171,7 @@ class StudyPlan(SQLModel, table=True): id: UUID = Field(default_factory=uuid4, primary_key=True) user_id: UUID = Field(foreign_key="user.id") date: date - tasks: Dict[str, Any] = Field(sa_type=JSON) # Array of {type, description, duration_minutes, status} + tasks: List[Dict[str, Any]] = Field(sa_type=JSON) # Array of {type, description, duration_minutes, status} is_completed: bool = Field(default=False) generated_at: datetime = Field(default_factory=datetime.utcnow) feedback: Optional[str] = None diff --git a/src/app/dashboard/ai-coach/tutor/page.tsx b/src/app/dashboard/ai-coach/tutor/page.tsx index fabf93b..25dbb98 100644 --- a/src/app/dashboard/ai-coach/tutor/page.tsx +++ b/src/app/dashboard/ai-coach/tutor/page.tsx @@ -1,52 +1,11 @@ -"use client" +"use client" import { TutorChat } from "@/components/AI/TutorChat" -import { BrainCircuit, Sparkles, MessageSquare, Lightbulb } from "lucide-react" -import { Card, CardContent } from "@/components/ui/card" - -const CAPABILITIES = [ - { icon: , label: "Concept Explanations", desc: "Step-by-step breakdown of Physics, Chemistry, Maths & Biology topics" }, - { icon: , label: "Problem Solving", desc: "Full worked solutions with formulas, derivations and shortcuts" }, - { icon: , label: "Doubt Clearing", desc: "Ask follow-up questions — the AI remembers context within the session" }, -] export default function TutorChatPage() { return ( -
- {/* Page Header */} -
-
-
-

- - - - AI Tutor — 24/7 Doubt Solver -

-

- Ask any JEE or NEET concept, get step-by-step explanations, formula derivations, and solved examples — instantly. -

-
-
-
- - {/* Capabilities Strip */} -
- {CAPABILITIES.map(c => ( - - -
{c.icon}
-
-
{c.label}
-
{c.desc}
-
-
-
- ))} -
- - {/* Chat — full height */} -
+
+
diff --git a/src/app/page.tsx b/src/app/page.tsx index eb409d3..b305f88 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -515,29 +515,29 @@ export default function MarketingPage() { {[ - { name: "Daily Practice Sheets", free: "1/day", pro: "Unlimited", ai: "Unlimited" }, - { name: "Answer Keys", free: true, pro: true, ai: true }, - { name: "Basic Progress Dashboard", free: true, pro: true, ai: true }, - { name: "Streak Tracking", free: true, pro: true, ai: true }, - { name: "Leaderboard (City/School)", free: true, pro: true, ai: true }, - { name: "Topic-wise Micro-tests", free: "5/day", pro: "Unlimited", ai: "Unlimited" }, - { name: "Weekly Test Series", free: false, pro: true, ai: true }, - { name: "Full-Length Mock Tests", free: false, pro: "4/month", ai: "Unlimited" }, - { name: "Previous Year Papers", free: false, pro: true, ai: true }, - { name: "Detailed Performance Analytics", free: false, pro: true, ai: true }, - { name: "Chapter-wise Progress", free: false, pro: true, ai: true }, - { name: "Doubt Resolution (Community)", free: false, pro: true, ai: true }, - { name: "Parent Dashboard", free: false, pro: true, ai: true }, - { name: "Offline Mode (Download DPS)", free: false, pro: true, ai: true }, - { name: "AI Mistake Tracking", free: false, pro: false, ai: true }, - { name: "Spaced Repetition", free: false, pro: false, ai: true }, - { name: "Personalized Daily Study Plan", free: false, pro: false, ai: true }, - { name: "AI Tutor Chat", free: false, pro: false, ai: true }, - { name: "Exam Readiness Score", free: false, pro: false, ai: true }, - { name: "Exam Day Strategy", free: false, pro: false, ai: true }, - { name: "College Predictor", free: false, pro: false, ai: true }, - { name: "Study Time Optimization", free: false, pro: false, ai: true }, - ].map((feature, idx) => ( + { name: "Basic Progress Dashboard", pro: true, ai: true }, + { name: "Streak Tracking", pro: true, ai: true }, + { name: "Leaderboard", pro: true, ai: true }, + { name: "Topic-wise Micro-tests", pro: true, ai: true }, + { name: "Weekly Test Series", pro: true, ai: true }, + { name: "Full-Length Mock Tests", pro: true, ai: true }, + { name: "Chapter-wise Progress", pro: true, ai: true }, + { name: "Doubt Resolution (Community)", pro: true, ai: true }, + { name: "Monthly Progress Report for Guardian", pro: true, ai: true }, + { name: "Parents Dashboard", pro: false, ai: true }, + { name: "Daily Practice Sheets", pro: false, ai: true }, + { name: "Answer Keys", pro: false, ai: true }, + { name: "Offline Mode (Download DPS)", pro: false, ai: true }, + { name: "AI Mistake Tracking", pro: false, ai: true }, + { name: "Spaced Repetition", pro: false, ai: true }, + { name: "Personalized Daily Study Plan", pro: false, ai: true }, + { name: "AI Tutor Chat", pro: false, ai: true }, + { name: "Exam Readiness Score", pro: false, ai: true }, + { name: "Exam Day Strategy", pro: false, ai: true }, + { name: "College Predictor", pro: false, ai: true }, + { name: "Study Time Optimization", pro: false, ai: true }, + { name: "Detailed Performance Analytics", pro: false, ai: true }, + ].map((feature, idx) => ( {feature.name} {/* diff --git a/src/app/upgrade/page.tsx b/src/app/upgrade/page.tsx index c11f8b8..986fb9a 100644 --- a/src/app/upgrade/page.tsx +++ b/src/app/upgrade/page.tsx @@ -120,28 +120,28 @@ export default function UpgradePage() { {[ - { name: "Daily Practice Sheets", free: "1/day", pro: "Unlimited", ai: "Unlimited" }, - { name: "Answer Keys", free: true, pro: true, ai: true }, - { name: "Basic Progress Dashboard", free: true, pro: true, ai: true }, - { name: "Streak Tracking", free: true, pro: true, ai: true }, - { name: "Leaderboard (City/School)", free: true, pro: true, ai: true }, - { name: "Topic-wise Micro-tests", free: "5/day", pro: "Unlimited", ai: "Unlimited" }, - { name: "Weekly Test Series", free: false, pro: true, ai: true }, - { name: "Full-Length Mock Tests", free: false, pro: "4/month", ai: "Unlimited" }, - { name: "Previous Year Papers", free: false, pro: true, ai: true }, - { name: "Detailed Performance Analytics", free: false, pro: true, ai: true }, - { name: "Chapter-wise Progress", free: false, pro: true, ai: true }, - { name: "Doubt Resolution (Community)", free: false, pro: true, ai: true }, - { name: "Parent Dashboard", free: false, pro: true, ai: true }, - { name: "Offline Mode (Download DPS)", free: false, pro: true, ai: true }, - { name: "AI Mistake Tracking", free: false, pro: false, ai: true }, - { name: "Spaced Repetition (SM-2)", free: false, pro: false, ai: true }, - { name: "Personalized Daily Study Plan", free: false, pro: false, ai: true }, - { name: "AI Tutor Chat", free: false, pro: false, ai: true }, - { name: "Exam Readiness Score", free: false, pro: false, ai: true }, - { name: "Exam Day Strategy", free: false, pro: false, ai: true }, - { name: "College Predictor", free: false, pro: false, ai: true }, - { name: "Study Time Optimization", free: false, pro: false, ai: true }, + { name: "Basic Progress Dashboard", pro: true, ai: true }, + { name: "Streak Tracking", pro: true, ai: true }, + { name: "Leaderboard", pro: true, ai: true }, + { name: "Topic-wise Micro-tests", pro: true, ai: true }, + { name: "Weekly Test Series", pro: true, ai: true }, + { name: "Full-Length Mock Tests", pro: true, ai: true }, + { name: "Chapter-wise Progress", pro: true, ai: true }, + { name: "Doubt Resolution (Community)", pro: true, ai: true }, + { name: "Monthly Progress Report for Guardian", pro: true, ai: true }, + { name: "Parents Dashboard", pro: false, ai: true }, + { name: "Daily Practice Sheets", pro: false, ai: true }, + { name: "Answer Keys", pro: false, ai: true }, + { name: "Offline Mode (Download DPS)", pro: false, ai: true }, + { name: "AI Mistake Tracking", pro: false, ai: true }, + { name: "Spaced Repetition", pro: false, ai: true }, + { name: "Personalized Daily Study Plan", pro: false, ai: true }, + { name: "AI Tutor Chat", pro: false, ai: true }, + { name: "Exam Readiness Score", pro: false, ai: true }, + { name: "Exam Day Strategy", pro: false, ai: true }, + { name: "College Predictor", pro: false, ai: true }, + { name: "Study Time Optimization", pro: false, ai: true }, + { name: "Detailed Performance Analytics", pro: false, ai: true }, ].map((feature, idx) => ( {feature.name} diff --git a/src/components/AI/TutorChat.tsx b/src/components/AI/TutorChat.tsx index b90ba4f..00470a8 100644 --- a/src/components/AI/TutorChat.tsx +++ b/src/components/AI/TutorChat.tsx @@ -1,4 +1,4 @@ -"use client" +"use client" import { fetchWithAuth } from "@/lib/apiClient"; import { useState, useRef, useEffect } from "react" @@ -33,6 +33,25 @@ export function TutorChat() { const { userId, loading: userLoading } = useActiveUser(); + // Load from localStorage on mount + useEffect(() => { + if (userId) { + const saved = localStorage.getItem("ai_tutor_chat_" + userId) + if (saved) { + try { + setMessages(JSON.parse(saved)) + } catch (e) {} + } + } + }, [userId]) + + // Save to localStorage whenever messages change + useEffect(() => { + if (userId && messages.length > 1) { // Only save if there's actual history beyond initial message + localStorage.setItem("ai_tutor_chat_" + userId, JSON.stringify(messages)) + } + }, [messages, userId]) + const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: "smooth" }) }