generic-error-boundary-fallback.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { FC } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import Icon from './icon'
  4. import { useLocation } from '../hooks/use-location'
  5. import { DefaultMessage } from './default-message'
  6. import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
  7. import MaterialIcon from './material-icon'
  8. import OLButton from '@/features/ui/components/ol/ol-button'
  9. export const GenericErrorBoundaryFallback: FC = ({ children }) => {
  10. const { t } = useTranslation()
  11. const { reload: handleClick } = useLocation()
  12. return (
  13. <div className="error-boundary-container">
  14. <BootstrapVersionSwitcher
  15. bs3={
  16. <Icon
  17. accessibilityLabel={`${t('generic_something_went_wrong')} ${t(
  18. 'please_refresh'
  19. )}`}
  20. type="exclamation-triangle fa-2x"
  21. fw
  22. />
  23. }
  24. bs5={
  25. <MaterialIcon
  26. accessibilityLabel={`${t('generic_something_went_wrong')} ${t(
  27. 'please_refresh'
  28. )}`}
  29. type="warning"
  30. size="2x"
  31. />
  32. }
  33. />
  34. {children || (
  35. <div className="error-message">
  36. <DefaultMessage className="small" style={{ fontWeight: 'bold' }} />
  37. </div>
  38. )}
  39. <OLButton variant="primary" onClick={handleClick}>
  40. {t('refresh')}
  41. </OLButton>
  42. </div>
  43. )
  44. }