"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { Badge } from "@/components/ui/badge"; import { useSpace } from "@/components/SpaceProvider"; import { FileText, Users, Settings, LayoutDashboard, Coins } from "lucide-react"; export function SpaceNav() { const pathname = usePathname(); const { space, membership } = useSpace(); const links = [ { href: "/", label: "Dashboard", icon: LayoutDashboard }, { href: "/proposals", label: "Proposals", icon: FileText }, { href: "/members", label: "Members", icon: Users }, ...(membership?.role === "ADMIN" ? [{ href: "/settings", label: "Settings", icon: Settings }] : []), ]; // Strip the /s/[slug] prefix to match against subdomain-style paths const cleanPath = pathname.replace(/^\/s\/[^/]+/, "") || "/"; return (
{links.map((link) => { const isActive = cleanPath === link.href || (link.href !== "/" && cleanPath.startsWith(link.href)); return ( {link.label} ); })}
{membership && (
{membership.credits} credits
)}
); }