import React from 'react'; import ChatMessageAttachmentEntity from '../../../../../Domain/entity/ChatMessageAttachmentEntity'; import DefaultAttachment from './DefaultAttachment/DefaultAttachment'; import { FileType } from '../../../../../Domain/entity/FileTypes'; import VideoAttachment from './VideoAttachment/VideoAttachment'; import ImagePlay from '../../../../components/UI/svgs/Icons/Toggle/ImagePlay'; import AudioAttachment from './AudioAttachment/AudioAttachment'; import AudioFile from '../../../../components/UI/svgs/Icons/Media/AudioFile'; import ImageAttachment from './ImageAttachment/ImageAttachment'; import ImageEmpty from '../../../../components/UI/svgs/Icons/Media/ImageEmpty'; import ImageFile from '../../../../components/UI/svgs/Icons/Media/ImageFile'; import UiKitTheme from '../../../../themes/UiKitTheme'; type AttachmentProps = { attachment: ChatMessageAttachmentEntity; }; type AttachmentContentComponentProps = AttachmentProps & { theme?: UiKitTheme; }; function renderAttachment({ attachment }: AttachmentProps) { if (attachment.type.toString().includes(FileType.video)) { return attachment.file ? ( ) : ( ); } if (attachment.type.toString().includes(FileType.audio)) { return attachment.file ? ( ) : ( ); } if (attachment.type.toString().includes(FileType.image)) { return attachment.file ? ( ) : ( ); } if (attachment.type.toString().includes(FileType.text)) { return attachment.file ? ( //
TEXT
) : ( ); } return ( ); } function MessageAttachment({ attachment, theme, }: AttachmentContentComponentProps) { const contentPlaceHolder = renderAttachment({ attachment }); let contentResult: JSX.Element = (
{contentPlaceHolder}
); if (attachment.type === FileType.text) { contentResult = (
{contentPlaceHolder}
{attachment.name || 'file'}
); } return contentResult; } export default MessageAttachment;