diff --git a/messages/en.json b/messages/en.json index 316e4ba..7c9b26f 100644 --- a/messages/en.json +++ b/messages/en.json @@ -11,6 +11,14 @@ "morePages": "More pages", "page": "page" }, + "error": { + "notFound": "404 - Page not found", + "notFoundDescription": "Oops! Looks like this page got lost in cyberspace.", + "error": "Oops! Something went wrong", + "errorDescription": "Don't worry, our best hackers are on it!", + "goToHomepage": "Return to homepage", + "tryAgain": "Try again" + }, "layout": { "hackerspaceHome": "Hackerspace homepage", "navigationMenu": "Navigation menu", diff --git a/messages/no.json b/messages/no.json index 79286cb..a832c42 100644 --- a/messages/no.json +++ b/messages/no.json @@ -11,6 +11,14 @@ "morePages": "Flere sider", "page": "side" }, + "error": { + "notFound": "404 - Siden ble ikke funnet", + "notFoundDescription": "Oops! Ser ut som denne siden gikk seg vill i cyberspace.", + "error": "Oops! Noe gikk galt", + "errorDescription": "Ikke bekymre deg, våre beste hackere jobber med saken!", + "goToHomepage": "Gå tilbake til hjemmesiden", + "tryAgain": "Prøv igjen" + }, "layout": { "hackerspaceHome": "Hackerspace hjemmeside", "navigationMenu": "Navigasjonsmeny", diff --git a/package.json b/package.json index 4b7093b..1277f30 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "prepare": "if [ \"$NODE_ENV\" != \"production\" ]; then lefthook install; fi", - "dev": "next dev --turbo", + "dev": "next dev", "lint": "biome check --write", "prebuild": "next telemetry disable", "build": "next build", diff --git a/src/app/[locale]/error.tsx b/src/app/[locale]/error.tsx new file mode 100644 index 0000000..a839b0a --- /dev/null +++ b/src/app/[locale]/error.tsx @@ -0,0 +1,44 @@ +'use client'; + +import { Button } from '@/components/ui/Button'; +import { Link } from '@/lib/locale/navigation'; +import { AlertTriangleIcon } from 'lucide-react'; +import { useTranslations } from 'next-intl'; +import { useEffect } from 'react'; + +export default function ErrorPage({ + error, + reset, +}: { + error: Error; + reset: () => void; +}) { + const t = useTranslations('error'); + useEffect(() => { + console.error(error); + }, [error]); + return ( +
+ +

+ {t('error')} +

+

+ {t('errorDescription')} +

+ {error.message && ( +

+ Error: {error.message} +

+ )} +
+ + +
+
+ ); +} diff --git a/src/app/[locale]/not-found.tsx b/src/app/[locale]/not-found.tsx new file mode 100644 index 0000000..e97706f --- /dev/null +++ b/src/app/[locale]/not-found.tsx @@ -0,0 +1,22 @@ +import { Button } from '@/components/ui/Button'; +import { Link } from '@/lib/locale/navigation'; +import { HardDriveIcon } from 'lucide-react'; +import { useTranslations } from 'next-intl'; + +export default function NotFoundPage() { + const t = useTranslations('error'); + return ( +
+ +

+ {t('notFound')} +

+

+ {t('notFoundDescription')} +

+ +
+ ); +} diff --git a/src/app/not-found.tsx b/src/app/not-found.tsx index 3f80952..5dd6846 100644 --- a/src/app/not-found.tsx +++ b/src/app/not-found.tsx @@ -1,9 +1,13 @@ 'use client'; -import { routing } from '@/lib/locale'; -import { redirect, usePathname } from 'next/navigation'; +import NextError from 'next/error'; -export default function NotFound() { - const pathname = usePathname(); - redirect(`/${routing.defaultLocale}/${pathname}`); +export default function NotFoundPage() { + return ( + + + + + + ); } diff --git a/src/components/providers/IntlErrorProvider.tsx b/src/components/providers/IntlErrorProvider.tsx index afead1f..197c9c3 100644 --- a/src/components/providers/IntlErrorProvider.tsx +++ b/src/components/providers/IntlErrorProvider.tsx @@ -6,12 +6,9 @@ type Props = { }; function IntlErrorProvider({ children, locale }: Props) { - const messages = useMessages(); + const { error } = useMessages(); return ( - + {children} );