file-view-refresh-error.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import type { ElementType } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import importOverleafModules from '../../../../macros/import-overleaf-module.macro'
  4. import { BinaryFile } from '../types/binary-file'
  5. type FileViewRefreshErrorProps = {
  6. file: BinaryFile
  7. refreshError: string
  8. }
  9. const tprFileViewRefreshError = importOverleafModules(
  10. 'tprFileViewRefreshError'
  11. ) as {
  12. import: { TPRFileViewRefreshError: ElementType }
  13. path: string
  14. }[]
  15. export default function FileViewRefreshError({
  16. file,
  17. refreshError,
  18. }: FileViewRefreshErrorProps) {
  19. const { t } = useTranslation()
  20. if (tprFileViewRefreshError.length > 0) {
  21. return tprFileViewRefreshError.map(
  22. ({ import: { TPRFileViewRefreshError }, path }) => (
  23. <TPRFileViewRefreshError
  24. key={path}
  25. file={file}
  26. refreshError={refreshError}
  27. />
  28. )
  29. )[0]
  30. } else {
  31. return (
  32. <div className="row">
  33. <br />
  34. <div className="alert alert-danger col-md-6 col-md-offset-3">
  35. {t('access_denied')}: {refreshError}
  36. </div>
  37. </div>
  38. )
  39. }
  40. }