Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | 1x 6x | 'use client'
import { Box, Typography, Button, Paper } from '@mui/material'
interface ErrorMessageProps {
message: string
onRetry?: () => void
}
/**
* ErrorMessage Component
* Displays an error message with an optional retry button.
*/
export function ErrorMessage({ message, onRetry }: ErrorMessageProps) {
return (
<Box
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
minHeight: '50vh',
}}
data-testid="error-message"
>
<Paper
sx={{
p: 4,
textAlign: 'center',
maxWidth: 400,
}}
>
<Typography variant="h5" color="error" gutterBottom>
Oops! Something went wrong
</Typography>
<Typography variant="body1" color="text.secondary" paragraph>
{message}
</Typography>
{onRetry && (
<Button
variant="contained"
color="primary"
onClick={onRetry}
data-testid="retry-button"
>
Try Again
</Button>
)}
</Paper>
</Box>
)
}
|