file-view-refresh-error.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. import OLNotification from '@/shared/components/ol/ol-notification'
  6. type FileViewRefreshErrorProps = {
  7. file: BinaryFile
  8. refreshError: string
  9. }
  10. const tprFileViewRefreshError = importOverleafModules(
  11. 'tprFileViewRefreshError'
  12. ) as {
  13. import: { TPRFileViewRefreshError: ElementType }
  14. path: string
  15. }[]
  16. export default function FileViewRefreshError({
  17. file,
  18. refreshError,
  19. }: FileViewRefreshErrorProps) {
  20. const { t } = useTranslation()
  21. if (tprFileViewRefreshError.length > 0) {
  22. return tprFileViewRefreshError.map(
  23. ({ import: { TPRFileViewRefreshError }, path }) => (
  24. <TPRFileViewRefreshError
  25. key={path}
  26. file={file}
  27. refreshError={refreshError}
  28. />
  29. )
  30. )[0]
  31. } else {
  32. return (
  33. <div className="file-view-error">
  34. <OLNotification
  35. type="error"
  36. content={
  37. <span>
  38. {t('access_denied')}: {refreshError}
  39. </span>
  40. }
  41. />
  42. </div>
  43. )
  44. }
  45. }