|
1 | | -import { useRouteError } from "react-router-dom"; |
| 1 | +import { useRouteError, useNavigate } from "react-router-dom"; |
| 2 | +import { Button } from "@/components/ui/button"; |
| 3 | +import { Card, CardContent, CardFooter } from "@/components/ui/card"; |
| 4 | +import { AlertCircle } from "lucide-react"; |
| 5 | + |
| 6 | +interface RouterError { |
| 7 | + statusText?: string; |
| 8 | + message?: string; |
| 9 | + status?: number; |
| 10 | +} |
2 | 11 |
|
3 | 12 | export default function ErrorPage() { |
4 | | - const error: any = useRouteError(); |
| 13 | + const error = useRouteError() as RouterError; |
| 14 | + const navigate = useNavigate(); |
5 | 15 | console.error(error); |
6 | 16 |
|
7 | 17 | return ( |
8 | | - <div id="error-page"> |
9 | | - <h1>Oops!</h1> |
10 | | - <p>Sorry, an unexpected error has occurred.</p> |
11 | | - <p> |
12 | | - <i>{error.statusText || error.message}</i> |
13 | | - </p> |
| 18 | + <div className="min-h-screen w-full flex items-center justify-center bg-background p-4"> |
| 19 | + <Card className="w-full max-w-md shadow-2xl rounded-2xl"> |
| 20 | + <CardContent className="pt-6 text-center space-y-4"> |
| 21 | + <div className="flex justify-center"> |
| 22 | + <AlertCircle className="h-12 w-12 text-destructive" /> |
| 23 | + </div> |
| 24 | + <h1 className="text-4xl font-bold tracking-tight">Oops!</h1> |
| 25 | + <p className="text-lg text-muted-foreground/80"> |
| 26 | + Sorry, an unexpected error has occurred. |
| 27 | + </p> |
| 28 | + <div className="p-4 bg-muted/70 rounded-lg"> |
| 29 | + <p className="text-sm text-destructive font-semibold italic"> |
| 30 | + {error.statusText || error.message} |
| 31 | + </p> |
| 32 | + </div> |
| 33 | + </CardContent> |
| 34 | + <CardFooter className="flex justify-center pb-6"> |
| 35 | + <Button |
| 36 | + variant="default" |
| 37 | + size="lg" |
| 38 | + onClick={() => navigate('/dashboard')} |
| 39 | + > |
| 40 | + Back to Dashboard |
| 41 | + </Button> |
| 42 | + </CardFooter> |
| 43 | + </Card> |
14 | 44 | </div> |
15 | 45 | ); |
16 | 46 | } |
0 commit comments