Skip to content

Free & Open-Source Invoice Generator - No Sign-Up, No Ads, Instant PDF Export, 100% In-Browser, and Fully Customizable Templates.

1.4 KB
Raw Blame
"use client";

import * as Sentry from "@sentry/nextjs";
import Link from "next/link";
import { useEffect } from "react";
import { toast } from "sonner";

import { ErrorMessage } from "@/components/etc/error-message";
import { Button } from "@/components/ui/button";

type Props = {
  error: Error;
  reset(): void;
};

export default function Error({ error, reset }: Props) {
  useEffect(() => {
    Sentry.captureException(error);

    toast.error(
      "Something went wrong! Please try to refresh the page or fill a bug report.",
      {
        id: "global-error-toast",
        closeButton: true,
        richColors: true,
      },
    );
  }, [error]);

  return (
    <div className="flex h-dvh flex-col items-center justify-center gap-4">
      <div className="flex flex-col items-center justify-center gap-4">
        <ErrorMessage>
          Something went wrong.
          <br /> Please try to refresh the page or fill a bug report{" "}
          <a
            href="https://pdfinvoicegenerator.userjot.com/board/bugs"
            className="underline"
            target="_blank"
            rel="noopener noreferrer"
          >
            here
          </a>
        </ErrorMessage>
      </div>
      <Button onClick={reset} variant="outline">
        Try again
      </Button>
      <Button asChild>
        <Link href="/">Return to homepage</Link>
      </Button>
    </div>
  );
}