From 0c6f1601920b30b8cccdedc8e4fd80873a4fe2f1 Mon Sep 17 00:00:00 2001 From: mbaharip <62494292+mbahArip@users.noreply.github.com> Date: Fri, 24 Jan 2025 17:44:16 +0700 Subject: [PATCH] update: Move error to component --- src/app/error.tsx | 54 +++-------------------------- src/components/Layout/Error.tsx | 61 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 49 deletions(-) create mode 100644 src/components/Layout/Error.tsx diff --git a/src/app/error.tsx b/src/app/error.tsx index 89c9190..4ed2119 100644 --- a/src/app/error.tsx +++ b/src/app/error.tsx @@ -1,56 +1,12 @@ "use client"; -import { useEffect } from "react"; - -import { Button } from "~/components/ui/button"; -import Icon from "~/components/ui/icon"; - -import useRouter from "~/hooks/usePRouter"; -import { cn } from "~/lib/utils"; +import ErrorComponent from "~/components/layout/Error"; export default function Error({ error, reset }: { error: Error & { digest?: string }; reset?: () => void }) { - const router = useRouter(); - useEffect(() => { - console.error(error); - }, [error]); - return ( -
- -
- Something went wrong - More details can be found in the console -
- - {error.message} - - -
- - -
-
+ ); } diff --git a/src/components/Layout/Error.tsx b/src/components/Layout/Error.tsx new file mode 100644 index 0000000..acd9059 --- /dev/null +++ b/src/components/Layout/Error.tsx @@ -0,0 +1,61 @@ +"use client"; + +import { useEffect } from "react"; + +import { Button } from "~/components/ui/button"; +import Icon from "~/components/ui/icon"; + +import useRouter from "~/hooks/usePRouter"; +import { cn } from "~/lib/utils"; + +type Props = { + error: Error & { digest?: string }; + reset?: () => void; +}; + +export default function ErrorComponent({ error, reset }: Props) { + const router = useRouter(); + useEffect(() => { + console.error(error); + }, [error]); + + return ( +
+ +
+ Something went wrong + More details can be found in the console +
+ + {error.message} + + +
+ + +
+
+ ); +}