Fix CBT submission, add CBT seeds, update features table, layout AI coach chat and add local memory

This commit is contained in:
2026-09-25 12:15:10 +05:30
parent ba4ab2049b
commit 21d7cac565
5 changed files with 70 additions and 92 deletions

View File

@@ -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" })
}