"use client";

import { Alert } from "flowbite-react";
import { HiInformationCircle } from "react-icons/hi";

import Button from "@/components/Button";
import { useRouter } from "next/navigation";
import { useEffect } from "react";

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  useEffect(() => {
    console.error(error);
  }, [error]);

  const router = useRouter();

  return (
    <div>
      <div className="grid fixed left-2/4 top-1/2 z-50">
        <Alert color="failure" icon={HiInformationCircle}>
          <span className="font-medium">Error alert!</span> Something went
          wrong!
        </Alert>
        <Button className="bg-gray-400 mt-3" onClick={() => router.push("/")}>
          Try again
        </Button>
      </div>
    </div>
  );
}
