pdf-validation-issue.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { memo } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import PropTypes from 'prop-types'
  4. import PreviewLogsPaneEntry from '../../preview/components/preview-logs-pane-entry'
  5. PdfValidationIssue.propTypes = {
  6. name: PropTypes.string.isRequired,
  7. issue: PropTypes.any,
  8. }
  9. function PdfValidationIssue({ issue, name }) {
  10. const { t } = useTranslation()
  11. switch (name) {
  12. case 'sizeCheck':
  13. return (
  14. <PreviewLogsPaneEntry
  15. headerTitle={t('project_too_large')}
  16. formattedContent={
  17. <>
  18. <div>{t('project_too_large_please_reduce')}</div>
  19. <ul className="list-no-margin-bottom">
  20. {issue.resources.map(resource => (
  21. <li key={resource.path}>
  22. {resource.path} &mdash; {resource.kbSize}
  23. kb
  24. </li>
  25. ))}
  26. </ul>
  27. </>
  28. }
  29. entryAriaLabel={t('validation_issue_entry_description')}
  30. level="error"
  31. />
  32. )
  33. case 'conflictedPaths':
  34. return (
  35. <PreviewLogsPaneEntry
  36. headerTitle={t('conflicting_paths_found')}
  37. formattedContent={
  38. <>
  39. <div>{t('following_paths_conflict')}</div>
  40. <ul className="list-no-margin-bottom">
  41. {issue.map(detail => (
  42. <li key={detail.path}>/{detail.path}</li>
  43. ))}
  44. </ul>
  45. </>
  46. }
  47. entryAriaLabel={t('validation_issue_entry_description')}
  48. level="error"
  49. />
  50. )
  51. case 'mainFile':
  52. return (
  53. <PreviewLogsPaneEntry
  54. headerTitle={t('main_file_not_found')}
  55. formattedContent={t('please_set_main_file')}
  56. entryAriaLabel={t('validation_issue_entry_description')}
  57. level="error"
  58. />
  59. )
  60. default:
  61. return null
  62. }
  63. }
  64. export default memo(PdfValidationIssue)