"use client";

import { ErrorView } from "@/components/ui/ErrorView";
import { usePathname } from "next/navigation";
import { useEffect } from "react";

export default function LocaleError({
    error,
    reset,
}: {
    error: Error & { digest?: string };
    reset: () => void;
}) {
    const pathname = usePathname();
    const isEn = pathname?.startsWith("/en");

    useEffect(() => {
        console.error(error);
    }, [error]);

    return (
        <ErrorView
            title="Oops!"
            descriptionPrimary={isEn ? "Something Went Wrong" : "Terjadi Kesalahan"}
            descriptionSecondary={
                isEn
                    ? "Please try again in a moment."
                    : "Silakan coba lagi beberapa saat lagi."
            }
            onRetry={reset}
        />
    );
}
