'use client'; import { useState, useRef, useEffect } from 'react'; import { Send } from 'lucide-react'; import type { ChatMessage } from '../MedOSGlobalApp'; import type { SupportedLanguage } from '@/lib/i18n'; import MessageBubble from '../chat/MessageBubble'; import TypingIndicator from '../chat/TypingIndicator'; import VoiceInput from '../chat/VoiceInput'; import QuickChips from '../chat/QuickChips'; import { trackSession } from '@/lib/analytics/anonymous-tracker'; interface ChatViewProps { messages: ChatMessage[]; isLoading: boolean; language: SupportedLanguage; onSendMessage: (message: string) => void; } const DEFAULT_TOPICS = [ 'Headache', 'Fever', 'Cough', 'Diabetes', 'Blood Pressure', 'Pregnancy', 'Mental Health', 'Child Health', ]; export default function ChatView({ messages, isLoading, language, onSendMessage, }: ChatViewProps) { const [input, setInput] = useState(''); const messagesEndRef = useRef(null); const inputRef = useRef(null); useEffect(() => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); }, [messages]); const handleSend = () => { if (!input.trim() || isLoading) return; trackSession(); onSendMessage(input); setInput(''); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSend(); } }; const handleVoiceTranscript = (text: string) => { trackSession(); onSendMessage(text); }; const handleQuickTopic = (topic: string) => { trackSession(); onSendMessage(topic); }; return (
{/* Mobile Header */}

MedOS

Free AI Medical Assistant
{/* Messages Area */}
{messages.length === 0 && (
🏥

Welcome to MedOS

Ask any health question. I provide general medical information in your language — free, private, and always available.

{/* Quick Start Topics */}
)} {messages.map((msg) => ( ))} {isLoading && messages[messages.length - 1]?.content === '' && ( )}
{/* Input Area */}
setInput(e.target.value)} onKeyDown={handleKeyDown} placeholder="Type your health question..." className="w-full bg-slate-800 border border-slate-700/50 rounded-xl px-4 py-3 text-sm text-slate-100 placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-medical-primary/50 focus:border-medical-primary/50 transition-all" disabled={isLoading} />
); }