import { Button } from "@/src/components/ui/button";
import { AlertCircle } from "lucide-react";
import { useSession } from "next-auth/react";
import { useRouter } from "next/router";
import { useEffect } from "react";
import Link from "next/link";
import { captureException } from "@sentry/nextjs";
export const ErrorPage = ({
title = "Error",
message,
additionalButton,
}: {
title?: string;
message: string;
additionalButton?:
| {
label: string;
href: string;
}
| {
label: string;
onClick: () => void;
};
}) => {
const session = useSession();
const router = useRouter();
const newTargetPath = router.asPath;
return (
{title}
{message}
{session.status === "unauthenticated" ? (
) : null}
{additionalButton ? (
"onClick" in additionalButton ? (
) : (
)
) : null}
);
};
export const ErrorPageWithSentry = ({
title = "Error",
message,
}: {
title?: string;
message: string;
}) => {
useEffect(() => {
// Capture the error with Sentry
if (window !== undefined)
captureException(
new Error(`ErrorPageWithSentry rendered: ${title}, ${message}`),
);
}, [title, message]); // Empty dependency array means this effect runs once on mount
return ;
};