"use client"; import Link from "next/link"; import { useTranslations } from "next-intl"; import { Alert, AlertDescription } from "@app/components/ui/alert"; import { Info } from "lucide-react"; import { useEnvContext } from "@app/hooks/useEnvContext"; import { usePaidStatus } from "@app/hooks/usePaidStatus"; import { tierMatrix } from "@server/lib/billing/tierMatrix"; import { build } from "@server/build"; import type { Env } from "@app/lib/types/env"; export function isIdpGlobalModeBannerVisible(env: Env): boolean { if (build === "saas") { return false; } return env.app.identityProviderMode === undefined; } export function IdpGlobalModeBanner() { const t = useTranslations(); const { env } = useEnvContext(); const { isPaidUser, hasEnterpriseLicense } = usePaidStatus(); const paidUserForOrgOidc = isPaidUser(tierMatrix.orgOidc); const enterpriseUnlicensed = build === "enterprise" && !hasEnterpriseLicense; if (!isIdpGlobalModeBannerVisible(env)) { return null; } const adminPanelLinkRenderer = (chunks: React.ReactNode) => ( {chunks} ); return ( {paidUserForOrgOidc ? t.rich("idpGlobalModeBanner", { adminPanelLink: adminPanelLinkRenderer, configDocsLink: (chunks) => ( {chunks} ) }) : enterpriseUnlicensed ? t.rich("idpGlobalModeBannerLicenseRequired", { adminPanelLink: adminPanelLinkRenderer }) : t.rich("idpGlobalModeBannerUpgradeRequired", { adminPanelLink: adminPanelLinkRenderer })} ); }