generic-error-boundary-fallback.tsx 949 B

12345678910111213141516171819202122232425262728293031
  1. import { FC } from 'react'
  2. import { useTranslation } from 'react-i18next'
  3. import { useLocation } from '../hooks/use-location'
  4. import { DefaultMessage } from './default-message'
  5. import MaterialIcon from './material-icon'
  6. import OLButton from '@/features/ui/components/ol/ol-button'
  7. export const GenericErrorBoundaryFallback: FC = ({ children }) => {
  8. const { t } = useTranslation()
  9. const { reload: handleClick } = useLocation()
  10. return (
  11. <div className="error-boundary-container">
  12. <MaterialIcon
  13. accessibilityLabel={`${t('generic_something_went_wrong')} ${t(
  14. 'please_refresh'
  15. )}`}
  16. type="warning"
  17. size="2x"
  18. />
  19. {children || (
  20. <div className="error-message">
  21. <DefaultMessage className="small" style={{ fontWeight: 'bold' }} />
  22. </div>
  23. )}
  24. <OLButton variant="primary" onClick={handleClick}>
  25. {t('refresh')}
  26. </OLButton>
  27. </div>
  28. )
  29. }