import type { OdFileObject } from '../../types' import { FC, useEffect, useRef, useState } from 'react' import { useRouter } from 'next/router' import Preview from 'preview-office-docs' import DownloadButtonGroup from '../DownloadBtnGtoup' import { DownloadBtnContainer } from './Containers' import { getBaseUrl } from '../../utils/getBaseUrl' import { getStoredToken } from '../../utils/protectedRouteHandler' const OfficePreview: FC<{ file: OdFileObject }> = ({ file }) => { const { asPath } = useRouter() const hashedToken = getStoredToken(asPath) const docContainer = useRef(null) const [docContainerWidth, setDocContainerWidth] = useState(600) const docUrl = encodeURIComponent( `${getBaseUrl()}/api/raw/?path=${asPath}${hashedToken ? `&odpt=${hashedToken}` : ''}` ) useEffect(() => { setDocContainerWidth(docContainer.current ? docContainer.current.offsetWidth : 600) }, []) return (
) } export default OfficePreview