import { useEffect } from "react"; import { getSignInHref, getSignInHrefForLocation } from "@/lib/auth-redirect"; import { isHostedClientAuthMode } from "@/lib/auth-mode"; type UnauthenticatedErrorCardProps = { message: string; onRetry?: () => void; }; export function UnauthenticatedErrorCard({ message, onRetry, }: UnauthenticatedErrorCardProps) { const isHostedMode = isHostedClientAuthMode(); const signInHref = typeof window === "undefined" ? getSignInHref("/") : getSignInHrefForLocation(window.location); useEffect(() => { if (typeof window === "undefined" || !isHostedMode) { return; } window.location.replace(signInHref); }, [isHostedMode, signInHref]); if (isHostedMode) { return null; } return (

Authentication required

{message}

This deployment uses external authentication. Refresh your access session, then try again.

{onRetry ? (
) : null}
); }