import Link from "next/link"; import { isAdminIdentity } from "@/lib/auth/admin"; import { KontiaMark } from "@/components/app/kontia-mark"; import { getCurrentUser } from "@/lib/auth/user"; import { cn } from "@/lib/utils"; import { getHeaderVisibility, type HeaderModeRequest } from "@/lib/layout/header"; type PageShellProps = { children: React.ReactNode; title: string; description?: string; action?: React.ReactNode; className?: string; showPageHeading?: boolean; headerMode?: HeaderModeRequest; headerBackHref?: string; headerBackLabel?: string; headerNextHref?: string; headerNextLabel?: string; headerShowManual?: boolean; headerPlanBadgeLabel?: string; headerAction?: React.ReactNode; headerShowLogout?: boolean; contentWidth?: "default" | "wide"; }; function HeaderBadge({ label }: { label: string }) { return {label}; } export async function PageShell({ children, title, description, action, className, showPageHeading = true, headerMode = "auto", headerBackHref = "/dashboard", headerBackLabel = "Volver al Dashboard", headerNextHref, headerNextLabel, headerShowManual = false, headerPlanBadgeLabel, headerAction, headerShowLogout = true, contentWidth = "default", }: PageShellProps) { const currentUser = await getCurrentUser(); const isAdmin = currentUser ? isAdminIdentity(currentUser.email, currentUser.role) : false; const visibility = getHeaderVisibility(Boolean(currentUser), headerMode); const containerClassName = contentWidth === "wide" ? "max-w-[1560px]" : "max-w-[1200px]"; return (
{visibility.showBackLink ? ( {headerBackLabel} ) : ( )} {visibility.showMarketingNav ? ( ) : null}
{visibility.showUserControls && headerShowManual ? ( Manual ) : null} {visibility.showUserControls && headerNextHref && headerNextLabel ? ( {headerNextLabel} ) : null} {visibility.showUserControls && headerAction ? headerAction : null} {visibility.showUserControls && headerPlanBadgeLabel ? : null} {isAdmin && currentUser && visibility.mode === "app" ? ( Admin ) : null} {visibility.showUserControls && headerShowLogout ? (
) : null} {visibility.showAuthButtons ? ( <> Iniciar Sesion Comenzar Gratis ) : null}
{showPageHeading ? (

{title}

{description ?

{description}

: null}
{action ?
{action}
: null}
) : null}
{children}
); }