import { ExceptiveType, Images } from '@/constants/common'; import { api_host } from '@/utils/api'; import { Flex, Image } from 'antd'; import FileViewer from 'react-file-viewer'; import { useParams, useSearchParams } from 'umi'; import Excel from './excel'; import Pdf from './pdf'; import styles from './index.less'; // TODO: The interface returns an incorrect content-type for the SVG. const isNotExceptiveType = (ext: string) => ExceptiveType.indexOf(ext) === -1; const DocumentViewer = () => { const { id: documentId } = useParams(); const api = `${api_host}/file/get/${documentId}`; const [currentQueryParameters] = useSearchParams(); const ext = currentQueryParameters.get('ext'); const onError = (e: any) => { console.error(e, 'error in file-viewer'); }; return (
{Images.includes(ext!) && ( )} {ext === 'pdf' && } {(ext === 'xlsx' || ext === 'xls') && } {isNotExceptiveType(ext!) && ( )}
); }; export default DocumentViewer;