import { Avatar, Typography } from 'antd'; import { UserOutlined } from '@ant-design/icons'; interface Props { senderRole: 'patient' | 'doctor' | 'system'; senderName?: string; content: string; contentType?: string; createdAt: string; } const ROLE_CONFIG = { patient: { align: 'flex-start' as const, bg: '#f0f0f0', color: '#000' }, doctor: { align: 'flex-end' as const, bg: '#1890ff', color: '#fff' }, system: { align: 'center' as const, bg: '#fafafa', color: '#999' }, }; export function ChatBubble({ senderRole, senderName, content, createdAt, }: Props) { const cfg = ROLE_CONFIG[senderRole] ?? ROLE_CONFIG.system; if (senderRole === 'system') { return (
{content}
); } return (
{senderRole === 'patient' && ( } style={{ marginRight: 8, flexShrink: 0 }} /> )}
{senderName && ( {senderName} )}
{content}
{createdAt}
{senderRole === 'doctor' && ( } style={{ marginLeft: 8, flexShrink: 0 }} /> )}
); }