generic-error-boundary-fallback.tsx 972 B

123456789101112131415161718192021222324252627282930313233
  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 '@/shared/components/ol/ol-button'
  7. export const GenericErrorBoundaryFallback: FC<React.PropsWithChildren> = ({
  8. children,
  9. }) => {
  10. const { t } = useTranslation()
  11. const { reload: handleClick } = useLocation()
  12. return (
  13. <div className="error-boundary-container">
  14. <MaterialIcon
  15. accessibilityLabel={`${t('generic_something_went_wrong')} ${t(
  16. 'please_refresh'
  17. )}`}
  18. type="warning"
  19. size="2x"
  20. />
  21. {children || (
  22. <div className="error-message">
  23. <DefaultMessage className="small" style={{ fontWeight: 'bold' }} />
  24. </div>
  25. )}
  26. <OLButton variant="primary" onClick={handleClick}>
  27. {t('refresh')}
  28. </OLButton>
  29. </div>
  30. )
  31. }