"use client";

import { useEffect } from "react";

import { Button, Typography } from "@/components/ui";

import styles from "./error.module.scss";

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  useEffect(() => {
    // eslint-disable-next-line no-console
    console.error(error);
  }, [error]);

  return (
    <div className={styles.coreError}>
      <Typography as="h2" size="xl" weight="bold">
        Something went wrong!
      </Typography>
      <Typography as="p" align="center">
        {error.message}
      </Typography>
      <Button onClick={() => reset()}>
        <Typography color="white">Try again</Typography>
      </Button>
    </div>
  );
}
