import { CONTENT_TYPE_TO_EXTENSION } from '@ringcentral-integration/utils/src/utils/fileHandler/constant'; import { RcIcon } from '@ringcentral/juno'; import { FileBorder } from '@ringcentral/juno-icon'; import clsx from 'clsx'; import type { FunctionComponent } from 'react'; import React from 'react'; import { getFileExtension, removeExtension, } from '../../../utils/src/utils/fileHandler/fileHandler'; import { DownloadButton } from '../DownloadButton'; import { getFileSize } from '../MessageInput/FileAttacher/utils/getFileSize'; import styles from './styles.scss'; interface IFileAttachmentRenderProps { attachment: { contentType: string; fileName: string; height: number; width: number; id: number; size: number; type: 'MmsAttachment'; uri: string; }; currentLocale: string; onLinkClick?: (href?: string) => void; } export const FileAttachmentRender: FunctionComponent< IFileAttachmentRenderProps > = ({ attachment, onLinkClick }) => { const fileName = attachment.fileName ? removeExtension(attachment.fileName) : attachment.id; const fileExt = attachment.fileName ? getFileExtension(attachment.fileName) : CONTENT_TYPE_TO_EXTENSION[attachment.contentType]; const fileSize = getFileSize(attachment.size); const downloadUrl = `${attachment.uri}&contentDisposition=Attachment`; return (