2021-06-29 15:20:35 +00:00
|
|
|
import { FunctionComponent, useEffect, useRef, useState } from 'react'
|
|
|
|
import Preview from 'preview-office-docs'
|
|
|
|
|
|
|
|
import DownloadBtn from '../DownloadBtn'
|
|
|
|
|
|
|
|
const OfficePreview: FunctionComponent<{ file: any }> = ({ file }) => {
|
|
|
|
const docContainer = useRef<HTMLDivElement>(null)
|
|
|
|
const [docContainerWidth, setDocContainerWidth] = useState(600)
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setDocContainerWidth(docContainer.current ? docContainer.current.offsetWidth : 600)
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2021-09-04 14:15:09 +00:00
|
|
|
<div className="overflow-scroll shadow" ref={docContainer} style={{ maxHeight: '90vh' }}>
|
2021-09-11 10:22:22 +00:00
|
|
|
<Preview url={encodeURIComponent(file['@microsoft.graph.downloadUrl'])} width={docContainerWidth.toString()} height="800" />
|
2021-06-29 15:20:35 +00:00
|
|
|
</div>
|
|
|
|
<div className="mt-4">
|
|
|
|
<DownloadBtn downloadUrl={file['@microsoft.graph.downloadUrl']} />
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default OfficePreview
|