"use client"; // ============================================================ // MoodCheckIn.tsx โ€” MEMBER 4 OWNS THIS // Emoji slider โ†’ writes to GUC.mentalWellness.stressLevel // If stress โ‰ค 3, calls store.setAvatarState("CONCERNED") // ============================================================ import { useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { useGUCStore } from "@/lib/store"; const MOODS = [ { emoji: "๐Ÿ˜ž", label: "Very Stressed", stress: 1, color: "#EF4444" }, { emoji: "๐Ÿ˜Ÿ", label: "Stressed", stress: 3, color: "#F97316" }, { emoji: "๐Ÿ˜", label: "Okay", stress: 5, color: "#EAB308" }, { emoji: "๐Ÿ˜Š", label: "Good", stress: 7, color: "#84CC16" }, { emoji: "๐Ÿ˜„", label: "Great!", stress: 9, color: "#22C55E" }, ]; interface MoodCheckInProps { onComplete?: () => void; } export default function MoodCheckIn({ onComplete }: MoodCheckInProps) { const mentalWellness = useGUCStore((s) => s.mentalWellness); const updateMentalWellness = useGUCStore((s) => s.updateMentalWellness); const setAvatarState = useGUCStore((s) => s.setAvatarState); const addXP = useGUCStore((s) => s.addXP); const [selectedMoodIndex, setSelectedMoodIndex] = useState(null); const [sleepRating, setSleepRating] = useState( mentalWellness.sleepQuality || 7 ); const [submitted, setSubmitted] = useState(false); const handleMoodSelect = (index: number) => { setSelectedMoodIndex(index); }; const handleSubmit = () => { if (selectedMoodIndex === null) return; const mood = MOODS[selectedMoodIndex]; updateMentalWellness(mood.stress, sleepRating); // If very stressed or low sleep โ†’ show concerned avatar if (mood.stress <= 3 || sleepRating <= 3) { setAvatarState("CONCERNED"); } else if (mood.stress >= 8) { setAvatarState("HAPPY"); } addXP(5); // +5 XP for daily check-in setSubmitted(true); onComplete?.(); }; const alreadyCheckedIn = mentalWellness.lastCheckin && new Date(mentalWellness.lastCheckin).toDateString() === new Date().toDateString(); if (submitted || alreadyCheckedIn) { const lastMood = MOODS.find( (m) => m.stress === mentalWellness.stressLevel ); return (

{lastMood?.emoji ?? "๐Ÿ˜Š"}

Today's check-in done!{" "} +5 XP earned

Stress: {mentalWellness.stressLevel}/10 ยท Sleep:{" "} {mentalWellness.sleepQuality}/10

); } return (
{/* Header */}

Daily Mood Check-in

How are you feeling today? +5 XP

{/* Emoji mood selector */}
{MOODS.map((mood, i) => ( handleMoodSelect(i)} className={`flex flex-col items-center gap-1 flex-1 py-2 rounded-xl transition-all ${ selectedMoodIndex === i ? "bg-white/10 ring-2" : "hover:bg-white/5" }`} style={ selectedMoodIndex === i ? { boxShadow: `0 0 0 2px ${mood.color}` } : {} } > {mood.emoji} {mood.label} ))}
{/* Sleep rating */}
Sleep Quality {sleepRating}/10
setSleepRating(Number(e.target.value))} className="w-full h-1.5 rounded-full appearance-none cursor-pointer" style={{ background: `linear-gradient(to right, #FF9933 0%, #FF9933 ${ (sleepRating - 1) * 11.11 }%, rgba(255,255,255,0.15) ${(sleepRating - 1) * 11.11}%, rgba(255,255,255,0.15) 100%)`, }} />
Poor ๐Ÿ˜ด Excellent ๐ŸŒ™
{/* Contextual message */} {selectedMoodIndex !== null && ( {MOODS[selectedMoodIndex].stress <= 3 ? (

Dr. Raahat is here for you ๐Ÿ’™ High stress can slow recovery. Try the 4-7-8 breathing exercise below.

) : MOODS[selectedMoodIndex].stress >= 8 ? (

Amazing! A positive mindset speeds up healing. Keep it up! ๐ŸŒŸ

) : (

Thank you for checking in. Consistency is what matters most.

)}
)}
{/* Submit button */} Save Check-in ยท +5 XP
); }