import { useState, useEffect, useRef } from 'react'; import ReactMarkdown from 'react-markdown'; import Stage1 from './Stage1'; import Stage2 from './Stage2'; import Stage3 from './Stage3'; import './ChatInterface.css'; export default function ChatInterface({ conversation, onSendMessage, isLoading, }) { const [input, setInput] = useState(''); const messagesEndRef = useRef(null); const scrollToBottom = () => { messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' }); }; useEffect(() => { scrollToBottom(); }, [conversation]); const handleSubmit = (e) => { e.preventDefault(); if (input.trim() && !isLoading) { onSendMessage(input); setInput(''); } }; const handleKeyDown = (e) => { // Submit on Enter (without Shift) if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); handleSubmit(e); } }; if (!conversation) { return (

🩺 Welcome to Nursing Council

Get expert feedback on your nursing education content from AI perspectives:

Create a new review to get started

); } return (
{conversation.messages.length === 0 ? (

Start a conversation

Paste your lesson plan, assessment, or educational content for review

) : ( conversation.messages.map((msg, index) => (
{msg.role === 'user' ? (
You
{msg.content}
) : (
🩺 Nursing Council
{/* Stage 1 */} {msg.loading?.stage1 && (
Stage 1: Council members reviewing your content...
)} {msg.stage1 && } {/* Stage 2 */} {msg.loading?.stage2 && (
Stage 2: Council members evaluating each other's feedback...
)} {msg.stage2 && ( )} {/* Stage 3 */} {msg.loading?.stage3 && (
Stage 3: Head of Nursing Education synthesizing recommendations...
)} {msg.stage3 && }
)}
)) )} {isLoading && (
The Nursing Council is deliberating...
)}
{conversation.messages.length === 0 && (