Skip to content

Commit 374fd8d

Browse files
authored
style: error-page (#4)
1 parent 7325939 commit 374fd8d

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

src/error-page.tsx

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
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+
}
211

312
export default function ErrorPage() {
4-
const error: any = useRouteError();
13+
const error = useRouteError() as RouterError;
14+
const navigate = useNavigate();
515
console.error(error);
616

717
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>
1444
</div>
1545
);
1646
}

0 commit comments

Comments
 (0)