/** * ChatMessage Component * Displays individual messages in the patient-student conversation */ import React from 'react'; import type { SimulationMessage } from '../types/simulation'; interface ChatMessageProps { message: SimulationMessage; index: number; } const ChatMessage: React.FC = ({ message, index }) => { const isStudent = message.role === 'student'; return (
{/* Role label */}
{isStudent ? 'You' : 'Patient'}
{/* Message content */}

{message.content}

{/* Timestamp */}
{new Date(message.timestamp).toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', })}
{/* Emotional state indicator (patient only) */} {!isStudent && message.emotional_state && (
Emotional state:
)}
); }; /** * Emotional State Badge */ const EmotionalStateBadge: React.FC<{ state: string }> = ({ state }) => { const stateConfig: Record = { calm: { color: 'bg-success/10 text-success', label: 'Calm', emoji: '😌' }, concerned: { color: 'bg-warning/10 text-warning', label: 'Concerned', emoji: '😟' }, anxious: { color: 'bg-error/10 text-error', label: 'Anxious', emoji: '😰' }, defensive: { color: 'bg-terracotta/10 text-terracotta', label: 'Defensive', emoji: '😤' }, }; const config = stateConfig[state] || stateConfig.calm; return ( {config.emoji} {config.label} ); }; export default ChatMessage;