Skip to content

Commit 213444f

Browse files
committed
feat: add basic error fallback
1 parent 62d6ce4 commit 213444f

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

messages/ar.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"subtitle": "أدخل رقم القضية لعرض تفاصيلها.",
55
"button": "بحث"
66
},
7+
"error": {
8+
"title": "حدث خطأ ما!",
9+
"subtitle": "القضية التي تبحث عنها غير موجودة بعد.",
10+
"button": "حاول مرة أخرى"
11+
},
712
"case": {
813
"title": "القضية",
914
"question": {

messages/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"subtitle": "Enter the case number to view its details.",
55
"button": "Search"
66
},
7+
"error": {
8+
"title": "Something went wrong!",
9+
"subtitle": "The case you are looking for doesn't exist yet.",
10+
"button": "Try again"
11+
},
712
"case": {
813
"title": "CASE",
914
"question": {

messages/es.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"subtitle": "Introduzca el número del caso para ver los detalles.",
55
"button": "Buscar"
66
},
7+
"error": {
8+
"title": "Algo salió mal",
9+
"subtitle": "El caso que estás buscando no existe aún.",
10+
"button": "Vuelva a intentarlo"
11+
},
712
"case": {
813
"title": "CASO",
914
"question": {

src/app/[locale]/error.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"use client";
2+
3+
import React from "react";
4+
5+
import clsx from "clsx";
6+
import { useLocale, useTranslations } from "next-intl";
7+
import Link from "next/link";
8+
9+
export default function Error({
10+
error: _,
11+
reset: __,
12+
}: {
13+
error: Error & { digest?: string };
14+
reset: () => void;
15+
}) {
16+
// useEffect(() => {
17+
// // Log the error to an error reporting service
18+
// console.error(error)
19+
// }, [error])
20+
21+
const t = useTranslations("error");
22+
const locale = useLocale();
23+
24+
return (
25+
<div className="mx-auto my-auto flex flex-col justify-center items-center">
26+
<h2 className="text-secondary-text text-xl font-bold text-center mb-4">
27+
{t("title")}
28+
</h2>
29+
<h3 className="text-secondary-text text-md text-center mb-4">
30+
{t("subtitle")}
31+
</h3>
32+
<Link
33+
href={`/${locale}`}
34+
className={clsx(
35+
"rounded bg-primary-blue hover:bg-secondary-blue transition w-max",
36+
"px-6 py-2 text-white-background font-semibold",
37+
)}
38+
>
39+
{t("button")}
40+
</Link>
41+
</div>
42+
);
43+
}

0 commit comments

Comments
 (0)