2026-06-07 03:58:32 -04:00
|
|
|
import Link from "next/link";
|
2026-06-07 17:54:30 -04:00
|
|
|
import { Mic, Plus, Wrench } from "lucide-react";
|
2026-06-07 03:58:32 -04:00
|
|
|
import { requireAuth } from "@/lib/auth/guards";
|
|
|
|
|
import { getEffectivePlan } from "@/lib/billing/subscription";
|
2026-06-07 17:54:30 -04:00
|
|
|
import { getActiveBranding, hexToHslTriplet } from "@/lib/branding";
|
|
|
|
|
import { isFlagEnabled } from "@/lib/flags";
|
2026-06-07 03:58:32 -04:00
|
|
|
import { SidebarNav } from "@/components/app/sidebar-nav";
|
2026-06-07 17:54:30 -04:00
|
|
|
import { AppMobileNav } from "@/components/app/app-mobile-nav";
|
2026-06-07 03:58:32 -04:00
|
|
|
import { UserMenu } from "@/components/app/user-menu";
|
2026-06-07 17:54:30 -04:00
|
|
|
import { CommandPalette } from "@/components/app/command-palette";
|
|
|
|
|
import { ImpersonationBanner } from "@/components/app/impersonation-banner";
|
|
|
|
|
import { ThemeProvider } from "@/components/providers/theme-provider";
|
2026-06-07 03:58:32 -04:00
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
|
|
|
|
|
|
// Authed, DB-backed dashboard — never statically prerender.
|
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
|
|
|
|
|
export default async function AppLayout({ children }: { children: React.ReactNode }) {
|
|
|
|
|
const session = await requireAuth();
|
2026-06-07 17:54:30 -04:00
|
|
|
const activeOrgId = session.session.activeOrganizationId;
|
|
|
|
|
const [{ key: plan }, branding, maintenance] = await Promise.all([
|
|
|
|
|
getEffectivePlan(session.user.id, activeOrgId),
|
|
|
|
|
getActiveBranding(session.user.id, activeOrgId),
|
|
|
|
|
isFlagEnabled("maintenance_banner"),
|
|
|
|
|
]);
|
2026-06-07 03:58:32 -04:00
|
|
|
const isAdmin = session.user.role === "admin";
|
|
|
|
|
|
2026-06-07 17:54:30 -04:00
|
|
|
// White-label: override the brand accent with the org's primary color so the
|
|
|
|
|
// whole app shell (logo tile, active nav, buttons) adopts it.
|
|
|
|
|
const brandHsl = hexToHslTriplet(branding?.primaryColor);
|
|
|
|
|
const brandStyle = brandHsl
|
|
|
|
|
? ({ "--brand": brandHsl, "--ring": brandHsl } as React.CSSProperties)
|
|
|
|
|
: undefined;
|
2026-06-20 20:12:43 -04:00
|
|
|
const workspaceName = branding?.brandName ?? "Podcast Distribution AI";
|
2026-06-07 17:54:30 -04:00
|
|
|
|
2026-06-07 03:58:32 -04:00
|
|
|
return (
|
2026-06-07 17:54:30 -04:00
|
|
|
<ThemeProvider>
|
|
|
|
|
<div className="flex min-h-screen flex-col" style={brandStyle}>
|
|
|
|
|
<ImpersonationBanner />
|
|
|
|
|
{maintenance && (
|
|
|
|
|
<div className="flex items-center justify-center gap-2 bg-warning px-4 py-2 text-center text-sm font-medium text-warning-foreground">
|
|
|
|
|
<Wrench className="h-4 w-4" />
|
|
|
|
|
We're performing scheduled maintenance — some features may be briefly unavailable.
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<header className="sticky top-0 z-30 flex h-16 items-center justify-between border-b border-border bg-background/85 px-4 backdrop-blur-md md:px-6">
|
|
|
|
|
<div className="flex items-center gap-1">
|
|
|
|
|
<AppMobileNav plan={plan} workspaceName={workspaceName} />
|
|
|
|
|
<Link href="/dashboard" className="flex items-center gap-2.5 font-display font-bold tracking-tight">
|
|
|
|
|
{branding?.logoUrl ? (
|
|
|
|
|
// eslint-disable-next-line @next/next/no-img-element
|
|
|
|
|
<img
|
|
|
|
|
src={branding.logoUrl}
|
|
|
|
|
alt={workspaceName}
|
|
|
|
|
className="h-8 w-auto max-w-[160px] object-contain"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<>
|
|
|
|
|
<span className="flex h-9 w-9 items-center justify-center rounded-2xl bg-brand text-brand-foreground">
|
|
|
|
|
<Mic className="h-5 w-5" />
|
|
|
|
|
</span>
|
|
|
|
|
<span className="hidden sm:inline">{workspaceName}</span>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
2026-06-07 03:58:32 -04:00
|
|
|
</Link>
|
2026-06-07 17:54:30 -04:00
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<Button asChild size="sm">
|
|
|
|
|
<Link href="/episodes/new">
|
|
|
|
|
<Plus className="h-4 w-4" /> New episode
|
|
|
|
|
</Link>
|
|
|
|
|
</Button>
|
|
|
|
|
<UserMenu
|
|
|
|
|
name={session.user.name}
|
|
|
|
|
email={session.user.email}
|
|
|
|
|
image={session.user.image}
|
|
|
|
|
isAdmin={isAdmin}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<div className="flex flex-1">
|
|
|
|
|
<aside className="hidden w-64 shrink-0 border-r border-border bg-background md:block">
|
|
|
|
|
<div className="sticky top-16">
|
|
|
|
|
<SidebarNav plan={plan} />
|
|
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
<main className="flex-1 bg-secondary/50">
|
|
|
|
|
<div className="container max-w-6xl py-8 md:py-10">{children}</div>
|
|
|
|
|
{branding && !branding.removePoweredBy && (
|
2026-06-20 20:12:43 -04:00
|
|
|
<p className="pb-8 text-center text-xs text-muted-foreground">Powered by Podcast Distribution AI</p>
|
2026-06-07 17:54:30 -04:00
|
|
|
)}
|
|
|
|
|
</main>
|
2026-06-07 03:58:32 -04:00
|
|
|
</div>
|
|
|
|
|
|
2026-06-07 17:54:30 -04:00
|
|
|
<CommandPalette />
|
2026-06-07 03:58:32 -04:00
|
|
|
</div>
|
2026-06-07 17:54:30 -04:00
|
|
|
</ThemeProvider>
|
2026-06-07 03:58:32 -04:00
|
|
|
);
|
|
|
|
|
}
|