import React from 'react'
import PropTypes from 'prop-types'
import { Dropdown, OverlayTrigger, Tooltip } from 'react-bootstrap'
import { useTranslation } from 'react-i18next'
import PreviewDownloadFileList from './preview-download-file-list'
import Icon from '../../../shared/components/icon'
function PreviewDownloadButton({
isCompiling,
outputFiles,
pdfDownloadUrl,
showText
}) {
const { t } = useTranslation()
let textStyle = {}
if (!showText) {
textStyle = {
position: 'absolute',
right: '-100vw'
}
}
const pdfDownloadDisabled = isCompiling || !pdfDownloadUrl
const buttonElement = (
{t('download_pdf')}
)
const hideTooltip = showText && pdfDownloadUrl
return (
{hideTooltip ? (
buttonElement
) : (
{pdfDownloadDisabled
? t('please_compile_pdf_before_download')
: t('download_pdf')}
}
>
{buttonElement}
)}
)
}
PreviewDownloadButton.propTypes = {
isCompiling: PropTypes.bool.isRequired,
outputFiles: PropTypes.array,
pdfDownloadUrl: PropTypes.string,
showText: PropTypes.bool.isRequired
}
export default PreviewDownloadButton