"use client"; import Link from "next/link"; import Image from "next/image"; import { useEffect, useMemo, useState } from "react"; import { apiFetch } from "@/lib/api"; import { BrandMark } from "@/components/ui/BrandMark"; export function PublicShell({ children }: { children: React.ReactNode }) { const [branding, setBranding] = useState<{ appName: string; logoUrl: string | null } | null>(null); const tenantSlug = useMemo(() => { if (typeof window === "undefined") return null; const u = new URL(window.location.href); return u.searchParams.get("tenantSlug"); }, []); useEffect(() => { const run = async () => { try { const data = await apiFetch<{ branding: { appName: string; logoUrl: string | null } }>( `/public/branding${tenantSlug ? `?tenantSlug=${encodeURIComponent(tenantSlug)}` : ""}` ); setBranding(data.branding); } catch { setBranding(null); } }; void run(); }, [tenantSlug]); const appName = branding?.appName ?? "EventSphere"; return (
{branding?.logoUrl ? ( {appName} ) : ( )} {appName} Enterprise Event Management Platform
Sign in Start Registration
{children}
); }