Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

feat: add not_found route #194

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions icons/FlipBackward.svg

This file was deleted.

13 changes: 13 additions & 0 deletions src/Page.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { render } from "./lib/test-utils";
import Page from "./Page";

test("render NotFound route", () => {
const { getByText, getByRole } = render(<Page />, {
routeConfig: {
initialEntries: ["/fake-route"],
},
});

expect(getByText(/Oops! There's nothing here/i)).toBeVisible();
expect(getByRole("button", { name: "Home" })).toBeVisible();
});
2 changes: 2 additions & 0 deletions src/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RouteChat } from "./routes/route-chat";
import { RouteDashboard } from "./routes/route-dashboard";
import { RouteCertificateSecurity } from "./routes/route-certificate-security";
import { RouteWorkspaceCreation } from "./routes/route-workspace-creation";
import { RouteNotFound } from "./routes/route-not-found";

export default function Page() {
return (
Expand All @@ -23,6 +24,7 @@ export default function Page() {
path="/certificates/security"
element={<RouteCertificateSecurity />}
/>
<Route path="*" element={<RouteNotFound />} />
</Routes>
);
}
34 changes: 34 additions & 0 deletions src/components/EmptyState.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
interface EmptyStateProps {
children?: React.ReactNode;
title?: string | React.ReactNode;
description?: string | React.ReactNode;
illustration?: React.ReactNode;
}

export function EmptyState({
illustration,
title,
children,
description,
}: EmptyStateProps) {
return (
<>
<div className="my-4">
{illustration != null && (
<div className="m-auto flex w-full justify-center pb-2">
{illustration}
</div>
)}
<div className="mb-1 text-center text-xl font-medium text-gray-900">
{title}
</div>
<div className="m-auto mb-6 text-center font-normal text-secondary">
{description}
</div>
{children != null && (
<div className="flex justify-center">{children}</div>
)}
</div>
</>
);
}
17 changes: 0 additions & 17 deletions src/components/icons/FlipBackward.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/icons/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export { default as Continue } from "./Continue";
export { default as Copilot } from "./Copilot";
export { default as Discord } from "./Discord";
export { default as FlipBackward } from "./FlipBackward";
export { default as Github } from "./Github";
export { default as Youtube } from "./Youtube";
22 changes: 22 additions & 0 deletions src/routes/route-not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { EmptyState } from "@/components/EmptyState";
import { IllustrationError, Button } from "@stacklok/ui-kit";
import { useNavigate } from "react-router-dom";
import { FlipBackward } from "@untitled-ui/icons-react";

export function RouteNotFound() {
const navigate = useNavigate();

return (
<div className="flex items-center justify-center h-full">
<EmptyState
title="Oops! There's nothing here"
description="Either the page you were looking for doesn’t exist or the link may be broken."
illustration={<IllustrationError className="w-1/2" />}
>
<Button variant="primary" onPress={() => navigate("/")}>
<FlipBackward /> Home
</Button>
</EmptyState>
</div>
);
}
Loading