Skip to content

Commit

Permalink
✨ feat(errors): implement error pages
Browse files Browse the repository at this point in the history
  • Loading branch information
thrownullexception committed Jul 20, 2024
1 parent 9fdd48f commit f13ae2b
Show file tree
Hide file tree
Showing 8 changed files with 1,000 additions and 0 deletions.
302 changes: 302 additions & 0 deletions src/frontend/views/errors/NotFound.tsx

Large diffs are not rendered by default.

345 changes: 345 additions & 0 deletions src/frontend/views/errors/ServerError.tsx

Large diffs are not rendered by default.

290 changes: 290 additions & 0 deletions src/frontend/views/errors/UnAuthorized.tsx

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions src/frontend/views/errors/_Base.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { msg } from "@lingui/macro";
import Head from "next/head";

import { SoftButton } from "@/components/app/button/soft";
import { useAppTheme } from "@/frontend/_layouts/useAppTheme";
import { useAppConfiguration } from "@/frontend/hooks/configuration/configuration.store";
import { NAVIGATION_LINKS } from "@/frontend/lib/routing/links";

interface IProps {
code: number;
message: string;
description: string;
Icon: React.ReactNode;
}

export function BaseErrorCmp({ code, description, message, Icon }: IProps) {
const {
data: { name },
} = useAppConfiguration("site_settings");

useAppTheme();

return (
<>
<Head>
<title>
{message} - {name}
</title>
</Head>
<div className="flex h-lvh w-lvw flex-col items-center justify-center gap-6 bg-foundation">
<div className="text-center">
<h1 className="text-4xl font-bold text-main">{code}</h1>
<h3 className="text-muted">{message}</h3>
</div>
{Icon}
<p className="text-muted">{description}</p>
<SoftButton
action={NAVIGATION_LINKS.DASHBOARD.HOME}
label={msg`Go Home`}
size="lg"
systemIcon="Home"
/>
</div>
</>
);
}
5 changes: 5 additions & 0 deletions src/pages/403.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { UnAuthorized } from "@/frontend/views/errors/UnAuthorized";

UnAuthorized.useAppLayout = false;

export default UnAuthorized;
5 changes: 5 additions & 0 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { NotFound } from "@/frontend/views/errors/NotFound";

NotFound.useAppLayout = false;

export default NotFound;
5 changes: 5 additions & 0 deletions src/pages/500.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ServerError } from "@/frontend/views/errors/ServerError";

ServerError.useAppLayout = false;

export default ServerError;
2 changes: 2 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
}

[data-theme="light"] {
color-scheme: light;
--dp-primary-text: var(--white);
--dp-primary: var(--app-primary);
--dp-primary-alpha-opacity: var(--light-primary-alpha-opacity);
Expand All @@ -30,6 +31,7 @@
}

[data-theme="dark"] {
color-scheme: dark;
--dp-primary: var(--app-primary);
--dp-primary-alpha-opacity: var(--dark-primary-alpha-opacity);
--dp-primary-alpha-text: var(--white);
Expand Down

0 comments on commit f13ae2b

Please sign in to comment.