pdf-file-list.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { MenuItem } from 'react-bootstrap'
  2. import { useTranslation } from 'react-i18next'
  3. import { memo } from 'react'
  4. import PropTypes from 'prop-types'
  5. function PdfFileList({ fileList }) {
  6. const { t } = useTranslation()
  7. if (!fileList) {
  8. return null
  9. }
  10. return (
  11. <>
  12. <MenuItem header>{t('other_output_files')}</MenuItem>
  13. {fileList.top.map(file => (
  14. <MenuItem download href={file.url} key={file.path}>
  15. <b>{file.path}</b>
  16. </MenuItem>
  17. ))}
  18. {fileList.other.length > 0 && fileList.top.length > 0 && (
  19. <MenuItem divider />
  20. )}
  21. {fileList.other.map(file => (
  22. <MenuItem download href={file.url} key={file.path}>
  23. <b>{file.path}</b>
  24. </MenuItem>
  25. ))}
  26. </>
  27. )
  28. }
  29. const FilesArray = PropTypes.arrayOf(
  30. PropTypes.shape({
  31. path: PropTypes.string.isRequired,
  32. url: PropTypes.string.isRequired,
  33. })
  34. )
  35. PdfFileList.propTypes = {
  36. fileList: PropTypes.shape({
  37. top: FilesArray,
  38. other: FilesArray,
  39. }),
  40. }
  41. export default memo(PdfFileList)