error-alert.tsx 594 B

12345678910111213141516171819202122232425262728293031
  1. import { useTranslation } from 'react-i18next'
  2. import OLNotification from '@/shared/components/ol/ol-notification'
  3. export type APIError = {
  4. message?: string
  5. }
  6. type ErrorAlertProps = {
  7. error?: APIError
  8. }
  9. export default function ErrorAlert({ error }: ErrorAlertProps) {
  10. const { t } = useTranslation()
  11. if (!error) {
  12. return null
  13. }
  14. if (error.message) {
  15. return (
  16. <OLNotification
  17. type="error"
  18. content={`${t('error')}: ${error.message}`}
  19. />
  20. )
  21. }
  22. return (
  23. <OLNotification type="error" content={t('generic_something_went_wrong')} />
  24. )
  25. }