import * as React from 'react'; import { useIntl } from 'react-intl'; import Modal from 'react-modal'; import { AxiosRequestConfig, AxiosResponse } from 'axios'; import ContentPreview, { ContentPreviewProps } from '../../content-preview'; import { TYPE_FILE, CLASS_MODAL_CONTENT_FULL_BLEED, CLASS_MODAL_OVERLAY, CLASS_MODAL } from '../../../constants'; import type { Token, BoxItem, Collection } from '../../../common/types/core'; import type APICache from '../../../utils/Cache'; import messages from '../messages'; export interface PreviewDialogProps { apiHost: string; appElement: HTMLElement; appHost: string; cache: APICache; canDownload: boolean; contentPreviewProps: ContentPreviewProps; currentCollection: Collection; isOpen: boolean; isTouch: boolean; item: BoxItem; onCancel: () => void; onDownload: (item: BoxItem) => void; onPreview: (data: unknown) => void; parentElement: HTMLElement; previewLibraryVersion: string; requestInterceptor?: (response: AxiosResponse) => void; responseInterceptor?: (config: AxiosRequestConfig) => void; sharedLink?: string; sharedLinkPassword?: string; staticHost: string; staticPath: string; token: Token; } const PreviewDialog = ({ apiHost, appElement, appHost, cache, canDownload, contentPreviewProps, currentCollection, isOpen, item, onCancel, onDownload, onPreview, parentElement, previewLibraryVersion, requestInterceptor, responseInterceptor, sharedLink, sharedLinkPassword, staticHost, staticPath, token, }: PreviewDialogProps) => { const { formatMessage } = useIntl(); const { items }: Collection = currentCollection; const onLoad = (data: unknown): void => { onPreview(data); }; if (!item || !items) { return null; } const files: BoxItem[] = items.filter(({ type }) => type === TYPE_FILE); return ( parentElement} portalClassName={CLASS_MODAL} > ); }; export default PreviewDialog;