import React from 'react'; import ForwardSvg from '../../../icons/actions/forward-filled.svg?react'; import ReplySvg from '../../../icons/actions/reply-filled.svg?react'; import './MessageCaption.scss'; interface MessageCaptionProps { type: 'outgoing' | 'incoming'; subtype?: 'reply' | 'forward'; userName: string; } const subtypeIconDictionary = { forward: ForwardSvg, reply: ReplySvg, }; const renderSubtype = (subtype: 'reply' | 'forward') => { const SubTypeIcon = subtypeIconDictionary[subtype]; return ( ); }; export default function MessageCaption({ type, subtype, userName, }: MessageCaptionProps) { return (
{subtype && renderSubtype(subtype)} {subtype === 'forward' && 'Forwarded from '} {subtype === 'reply' && 'Replied to '}
{(type === 'incoming' || subtype === 'reply' || subtype === 'forward') && (
{userName}
)}
); }