'use client'; import React, { useState, useEffect } from 'react' import { useAuth } from '@/components/providers/MockAuthProvider' import { useLanguage } from '@/components/providers/LanguageProvider' import { useRouter } from 'next/navigation' import { Heart, MessageCircle, Phone, Calendar, LogOut, Languages, ArrowLeft, AlertTriangle, CheckCircle, Clock, Users } from 'lucide-react' import Link from 'next/link' export default function WellbeingPage() { const { user, userProfile, logout } = useAuth() const { t, language, setLanguage } = useLanguage() const router = useRouter() const [messages, setMessages] = useState>([]) const [inputText, setInputText] = useState('') const [isTyping, setIsTyping] = useState(false) const [showEmergencyModal, setShowEmergencyModal] = useState(false) useEffect(() => { if (!user) { router.push('/') } }, [user, router]) useEffect(() => { // Start with a welcome message setMessages([ { id: '1', text: 'Hello! I\'m here to support your mental health and wellbeing. How are you feeling today?', sender: 'bot', timestamp: new Date() } ]) }, []) const handleSendMessage = async () => { if (!inputText.trim()) return const userMessage = inputText.trim() setInputText('') const newMessage = { id: Date.now().toString(), text: userMessage, sender: 'user' as const, timestamp: new Date() } setMessages(prev => [...prev, newMessage]) setIsTyping(true) try { const response = await fetch('/api/chat', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ message: userMessage, mode: 'mental_health', history: messages, }), }) const data = await response.json() setIsTyping(false) const botMessage = { id: (Date.now() + 1).toString(), text: data.response, sender: 'bot' as const, timestamp: new Date() } setMessages(prev => [...prev, botMessage]) // Check for escalation if (data.shouldEscalate) { setShowEmergencyModal(true) } } catch (error) { setIsTyping(false) console.error('Chat error:', error) } } const handleLogout = async () => { await logout() } const toggleLanguage = () => { setLanguage(language === 'en' ? 'ar' : 'en') } if (!user || !userProfile) { return (

Loading wellbeing support...

) } return (
{/* Header */}
Back to Dashboard
|

{t('wellbeing')} Support

{userProfile.name.charAt(0)}

{userProfile.name}

{userProfile.role}

{/* Main Content */}
{/* Welcome Section */}

Welcome to Mental Health Support

Your wellbeing is important to us. This is a safe space where you can talk about how you're feeling. Our AI assistant is trained to provide empathetic support and can connect you with professional help when needed.

{/* Emergency Resources */}

Emergency Resources

If you're experiencing a mental health emergency, please contact:

Crisis Line: 988
Campus Security: (555) 123-4567
{/* Chat Interface */}

Wellbeing Chat

{/* Messages */}
{messages.map((message) => (

{message.text}

{message.timestamp.toLocaleTimeString()}

))} {isTyping && (
Typing...
)}
{/* Input */}
setInputText(e.target.value)} onKeyPress={(e) => e.key === 'Enter' && handleSendMessage()} placeholder={t('type_message')} className="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-pink-500" />
{/* Sidebar */}
{/* Quick Actions */}

Quick Actions

{t('book_counselor')} Self-Care Resources
{/* Counseling Services */}

Counseling Services

Individual counseling
Group therapy sessions
Crisis intervention
Stress management workshops
{/* Office Hours */}

Office Hours

Monday - Friday 8:00 AM - 6:00 PM
Saturday 10:00 AM - 4:00 PM
Sunday Closed
24/7 Crisis Line Available
{/* Emergency Modal */} {showEmergencyModal && (

Emergency Support

If you're experiencing a mental health emergency, please contact one of these resources immediately:

Crisis Lifeline

988

Campus Counseling

(555) 123-4567

Schedule Appointment

Book with Counselor
Call 988
)}
) }