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"; import { stripBasePath } from "@/src/utils/redirect"; 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 = stripBasePath(router.asPath || "/"); // Only include targetPath if it's not the root (since "/" is the default anyway) const targetPathQuery = newTargetPath !== "/" ? `?targetPath=${encodeURIComponent(newTargetPath)}` : ""; return (

{title}

{message}

{session.status === "unauthenticated" ? ( ) : null} {additionalButton ? ( "onClick" in additionalButton ? ( ) : ( ) ) : null}
); }; export const ErrorPageWithSentry = ({ title = "Error", message, additionalButton, }: { title?: string; message: string; additionalButton?: | { label: string; href: string; } | { label: string; onClick: () => void; }; }) => { 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 ( ); };