import { Component } from 'react'; import Alert from '@mui/material/Alert'; import AlertTitle from '@mui/material/AlertTitle'; import Box from '@mui/material/Box'; import Button from '@mui/material/Button'; import Typography from '@mui/material/Typography'; import { formatBackendError } from '../utils/backendError'; class BackendError extends Component { render() { const { error, title, onRetry, sx, action } = this.props; if (!error) return null; const formatted = formatBackendError(error); const heading = title || formatted.title; return ( {heading} {formatted.detail ? ( {formatted.detail} ) : null} {formatted.request ? ( {formatted.request} {formatted.status != null ? ` → ${formatted.status}` : ''} ) : null} {onRetry ? ( ) : null} ); } } export default BackendError;