"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useAuth } from "../../lib/auth-store"; import { useBranding } from "../../lib/branding"; import { useApiResource } from "../../lib/use-api"; import type { DraftRecord } from "../../lib/api-types"; import { LogoMark } from "../brand/logo"; import { NavIcon } from "../brand"; const NAV: { href: string; label: string; icon: string; external?: boolean }[] = [ { href: "/streams", label: "Streams", icon: "video" }, { href: "/control-room", label: "Control Room", icon: "video" }, { href: "/compose", label: "Compose", icon: "compose" }, { href: "/calendar", label: "Calendar", icon: "calendar" }, { href: "/chat", label: "Chat", icon: "chat" }, { href: "/files", label: "Files", icon: "files" }, { href: "/archive", label: "Archive", icon: "files" }, { href: "/inbox", label: "Inbox", icon: "inbox" }, { href: "/outreach", label: "Outreach", icon: "team" }, { href: "/approvals", label: "Approvals", icon: "approvals" }, { href: "/video", label: "Video", icon: "video" }, { href: "/analytics", label: "Analytics", icon: "analytics" }, { href: "/connections", label: "Channels", icon: "connections" }, { href: "/team", label: "Team", icon: "team" }, { href: "/audit", label: "Audit log", icon: "audit" }, { href: "/onboarding", label: "Onboarding", icon: "home" }, { href: "/settings", label: "Settings", icon: "settings" }, ]; const identity = (drafts: DraftRecord[]): DraftRecord[] => drafts; const emptyDrafts: DraftRecord[] = []; export function Sidebar(): React.ReactElement { const pathname = usePathname(); const { session, can } = useAuth(); const branding = useBranding(); const drafts = useApiResource("/publishing/drafts", identity, emptyDrafts, { state: "in_review", limit: 100 }); // Real in-review count from the API; hidden while loading/offline and for non-approvers. const approvals = can("approval.grant") && drafts.source === "live" ? drafts.data.length : 0; // Branding is per collective; the session's workspace is the source of truth // for the name, branding only decorates it (and may be loading/unavailable). const workspaceName = session?.workspace.name ?? branding.workspaceName ?? "Studio"; const showTagline = branding.source === "live" && branding.tagline !== null; return ( ); }