import { type FC } from 'react' import moment from 'moment-jalaali' import { Paperclip2 } from 'iconsax-react' import { getFileNameAndExtensionFromUrl } from '@/config/func' import VoicePlayer from '@/components/VoicePlayer' import type { AttachmentsType } from '../type/Types' type Props = { content: string attachments?: AttachmentsType[] senderName?: string senderLabel?: string createdAt?: string isAdmin?: boolean } const TicketMessage: FC = ({ content, attachments = [], senderName, senderLabel = 'پشتیبان', createdAt, isAdmin = false, }) => { const fileAttachments = attachments.filter((a) => a.type !== 'voice') const voiceAttachments = attachments.filter((a) => a.type === 'voice') const handleOpenLink = (url: string) => { window.open(url, '_blank', 'noopener,noreferrer') } return (
{isAdmin && senderName && (
{senderLabel}: {senderName}
)} {content && (

{content}

)} {fileAttachments.length > 0 && (
{fileAttachments.map((attach) => ( ))}
)} {voiceAttachments.length > 0 && (
{voiceAttachments.map((voice) => ( ))}
)} {createdAt && (
{moment(createdAt).format('jYYYY/jMM/jDD HH:mm')}
)}
) } export default TicketMessage