"use client";

import { useEffect } from "react";

import { Button } from "@/components/ui/button";

export default function GlobalError({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  useEffect(() => {
    console.error(error);
  }, [error]);

  return (
    <div className="mx-auto flex min-h-[50vh] w-full max-w-md flex-col items-center justify-center gap-3 px-4 text-center">
      <h2 className="text-xl font-semibold text-emerald-900">Something went wrong</h2>
      <p className="text-sm text-muted-foreground">
        Please try again. If the issue persists, review your input and configuration.
      </p>
      <Button onClick={() => reset()}>Retry</Button>
    </div>
  );
}
