Skip to content

Commit 4b66bce

Browse files
authored
Add a 404 Not Found Page (#1182)
## Description <!-- Please provide a brief description of the changes made in this pull request. Include any relevant context or reasoning for the changes. --> A simple 404 not found page that allows the user to go back or home. Much better than our current default which is just: `<p>Not found</p>` ## Related Issue and Pull requests <!-- Link to any related issues using the format #<issue-number> --> ## Type of Change <!-- Please delete options that are not relevant --> - [x] Improvement ## Checklist <!-- Please ensure the following are completed before submitting the PR --> - [ ] I have tested this does not break current pipelines / runs functionality - [ ] I have tested the changes on staging ## Screenshots (if applicable) <!-- Include any screenshots that might help explain the changes or provide visual context --> ![image.png](https://app.graphite.dev/user-attachments/assets/49d2c1c4-96e9-4b34-b6d6-2ab6238ad30c.png) ## Test Instructions <!-- Detail steps and prerequisites for testing the changes in this PR --> navigate to a route that doesn't exist e.g. `/hello` ## Additional Comments <!-- Add any additional context or information that reviewers might need to know regarding this PR -->
1 parent c6af85f commit 4b66bce

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/routes/NotFoundPage.tsx

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { useRouter } from "@tanstack/react-router";
2+
import { useCallback } from "react";
3+
4+
import { Button } from "@/components/ui/button";
5+
import { BlockStack } from "@/components/ui/layout";
6+
import { Paragraph, Text } from "@/components/ui/typography";
7+
8+
export default function NotFoundPage() {
9+
const router = useRouter();
10+
11+
const handleGoHome = useCallback(() => {
12+
router.navigate({ to: "/" });
13+
}, [router]);
14+
15+
const handleGoBack = useCallback(() => {
16+
router.history.back();
17+
}, [router]);
18+
19+
return (
20+
<div className="min-h-screen flex items-center justify-center bg-background p-4">
21+
<div className="max-w-xs w-full">
22+
<BlockStack gap="8" align="center">
23+
<BlockStack gap="2" align="center">
24+
<Text size="2xl" weight="bold">
25+
Page not found
26+
</Text>
27+
<Paragraph tone="subdued" size="sm">
28+
The page you&apos;re looking for doesn&apos;t exist.
29+
</Paragraph>
30+
</BlockStack>
31+
32+
<BlockStack gap="3">
33+
<Button onClick={handleGoBack} className="w-full">
34+
Go Back
35+
</Button>
36+
37+
<Button
38+
onClick={handleGoHome}
39+
variant="secondary"
40+
className="w-full"
41+
>
42+
Go Home
43+
</Button>
44+
</BlockStack>
45+
</BlockStack>
46+
</div>
47+
</div>
48+
);
49+
}

src/routes/router.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import RootLayout from "../components/layout/RootLayout";
1313
import Editor from "./Editor";
1414
import ErrorPage from "./ErrorPage";
1515
import Home from "./Home";
16+
import NotFoundPage from "./NotFoundPage";
1617
import PipelineRun from "./PipelineRun";
1718
import { QuickStartPage } from "./QuickStart";
1819

@@ -37,6 +38,7 @@ export const APP_ROUTES = {
3738
const rootRoute = createRootRoute({
3839
component: Outlet,
3940
errorComponent: ErrorPage,
41+
notFoundComponent: NotFoundPage,
4042
});
4143

4244
const mainLayout = createRoute({

0 commit comments

Comments
 (0)