import { FunctionComponent } from 'react'; import 'react-image-crop/dist/ReactCrop.css'; import { DownloadFile } from '@/common/components/molecules/DownloadFile/DownloadFile'; import { ImageEditor } from '@/common/components/molecules/ImageEditor/ImageEditor'; import { ImageViewer } from '@/common/components/organisms/ImageViewer/ImageViewer'; import { ctw } from '@/common/utils/ctw/ctw'; import { isCsv } from '@/common/utils/is-csv/is-csv'; import { DocumentsToolbar } from '@/pages/Entity/components/Case/Case.Documents.Toolbar'; import { useDocumentsLogic } from './hooks/useDocuments/useDocumentsLogic'; import { IDocumentsProps } from './interfaces'; import { keyFactory } from '@/common/utils/key-factory/key-factory'; /** * @description To be used by {@link Case}, and be wrapped by {@link Case.Content}. Displays a single entity's documents using {@link ImageViewer}. Displays documents[0].imageUrl if no document was selected yet. * * @param props * @param props.documents - An array of objects containing the document's image URL and caption to pass into {@link ImageViewer.Item}. * @param props.isLoading - Whether the documents are still loading. * @param props.hideOpenExternalButton - Whether to hide the open external button. * * @see {@link ImageViewer} * * @constructor */ export const Documents: FunctionComponent = ({ documents, onOcrPressed, isLoading, isDocumentEditable, isLoadingOCR, hideOpenExternalButton, wrapperClassName, }) => { const { crop, onCrop, onCancelCrop, isCropping, selectedImageRef, initialImage, skeletons, selectedImage, onSelectImage, documentRotation, onRotateDocument, onOpenDocumentInNewTab, onTransformed, isRotatedOrTransformed, shouldDownload, isOCREnabled, fileToDownloadBase64, } = useDocumentsLogic(documents); return (
{!shouldDownload && ( )} {shouldDownload && (
)}
{isLoading ? skeletons.map(index => ( )) : documents?.map(document => { const { imageUrl, title, fileType, fileName, id } = document; return !isCsv(document) ? ( ) : null; })}
); };