error-alert.tsx 530 B

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