Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add generic error pages #181

Merged
merged 1 commit into from
Jan 23, 2024
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
38 changes: 38 additions & 0 deletions apps/web/src/app/[lang]/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use client";

import { Button } from "@tietokilta/ui";

export const metadata = {
title: "Jotain meni pieleen",
description: "Hups, jotain meni pieleen.",
};

// TODO: add i18n when next.js supports params in error pages https://github.com/vercel/next.js/discussions/43179

function Error({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
return (
<main className="relative mb-8 flex flex-col items-center gap-2 md:gap-6">
<header className="flex h-[15svh] w-full items-center justify-center bg-gray-900 text-gray-100 md:h-[25svh]">
<h1 className="font-mono text-4xl md:text-5xl">Jotain meni pieleen</h1>
</header>

<div className="relative m-auto flex max-w-prose flex-col gap-8 p-4 md:p-6">
<p className="shadow-solid max-w-prose rounded-md border-2 border-gray-900 p-4 md:p-6">
Oho, nyt meni jotain pieleen. Ota yhteyttä sivuston ylläpitäjään.
Virheen tunniste on <code className="font-mono">{error.digest}</code>.
</p>
<Button onClick={reset} type="button">
Yritä uudelleen
</Button>
</div>
</main>
);
}

export default Error;
47 changes: 47 additions & 0 deletions apps/web/src/app/[lang]/global-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use client";

import { Button } from "@tietokilta/ui";

export const metadata = {
title: "Tietokilta - Jotain meni pieleen",
description: "Hups, jotain meni pieleen.",
};

// TODO: add i18n when next.js supports params in global-error pages https://github.com/vercel/next.js/discussions/43179

function GlobalError({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
return (
<html lang="fi">
<body className="font-sans">
<div className="flex min-h-screen flex-col">
<main className="relative mb-8 flex flex-col items-center gap-2 md:gap-6">
<header className="flex h-[15svh] w-full items-center justify-center bg-gray-900 text-gray-100 md:h-[25svh]">
<h1 className="font-mono text-4xl md:text-5xl">
Jotain meni pieleen
</h1>
</header>

<div className="relative m-auto flex max-w-prose flex-col gap-8 p-4 md:p-6">
<p className="shadow-solid max-w-prose rounded-md border-2 border-gray-900 p-4 md:p-6">
Oho, nyt meni jotain pahasti pieleen. Ota yhteyttä sivuston
ylläpitäjään. Virheen tunniste on{" "}
<code className="font-mono">{error.digest}</code>.
</p>
<Button onClick={reset} type="button">
Yritä uudelleen
</Button>
</div>
</main>
</div>
</body>
</html>
);
}

export default GlobalError;
34 changes: 34 additions & 0 deletions apps/web/src/app/[lang]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"use client";

import { Button } from "@tietokilta/ui";
import Link from "next/link";

export const metadata = {
title: "404 - Sivua ei löytynyt",
description: "Sivua ei löytynyt.",
};

// TODO: add i18n when next.js supports params in not-found pages https://github.com/vercel/next.js/discussions/43179

function Page() {
return (
<main className="relative mb-8 flex flex-col items-center gap-2 md:gap-6">
<header className="flex h-[15svh] w-full items-center justify-center bg-gray-900 text-gray-100 md:h-[25svh]">
<h1 className="font-mono text-4xl md:text-5xl">
404 - Sivua ei löytynyt
</h1>
</header>

<div className="relative m-auto flex max-w-prose flex-col gap-8 p-4 md:p-6">
<p className="shadow-solid max-w-prose rounded-md border-2 border-gray-900 p-4 md:p-6">
Sivua ei löytynyt. Tarkista osoite tai palaa etusivulle.
</p>
<Button asChild variant="link">
<Link href="/">Etusivulle</Link>
</Button>
</div>
</main>
);
}

export default Page;
Loading