import MessageAttachmentInfo from '@rc-ex/core/lib/definitions/MessageAttachmentInfo'; import { getFileExtension, removeExtension, } from '@ringcentral-integration/utils'; import { CONTENT_TYPE_TO_EXTENSION } from '@ringcentral-integration/utils/src/utils/fileHandler/constant'; import clsx from 'clsx'; import type { FunctionComponent } from 'react'; import React, { Suspense } from 'react'; import { DownloadButton } from '../DownloadButton'; import styles from './styles.scss'; const TiffViewer = React.lazy(() => import('./TiffViewer')); export interface ImageAttachmentRenderProps { attachment: MessageAttachmentInfo; handleImageLoad?: () => void; } export const ImageAttachmentRender: FunctionComponent< ImageAttachmentRenderProps > = (props) => { const { attachment, handleImageLoad, ...rest } = props; const uri = attachment.uri; const fileNameWithoutExt = attachment.fileName ? removeExtension(attachment.fileName) : attachment.id; const fileExt = attachment.fileName ? getFileExtension(attachment.fileName) : CONTENT_TYPE_TO_EXTENSION[attachment.contentType!]; const fileName = `${fileNameWithoutExt}.${fileExt}`; const isTiff = fileExt.indexOf('tif') > -1; return (