"use client"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { cn } from "@/lib/utils"; import { LayoutGrid, Cable, Key, Users, Settings, DollarSign, LogOut, } from "lucide-react"; import { Separator } from "@/components/ui/separator"; import { signOut } from "@/lib/firebase/auth"; import { toast } from "sonner"; interface WorkspaceLeftRailProps { activeSection?: string; onSectionChange: (section: string) => void; } const navItems = [ { id: 'projects', label: 'Projects', icon: LayoutGrid, href: '/projects', }, { id: 'connections', label: 'Connect', icon: Cable, href: '/connections', }, { id: 'keys', label: 'Keys', icon: Key, href: '/keys', }, { id: 'costs', label: 'Costs', icon: DollarSign, href: '/costs', }, { id: 'users', label: 'Users', icon: Users, href: '/users', }, ]; export function WorkspaceLeftRail({ activeSection = 'projects', onSectionChange }: WorkspaceLeftRailProps) { const pathname = usePathname(); const router = useRouter(); // Extract workspace from pathname (e.g., /marks-account/projects -> marks-account) const workspace = pathname?.split('/')[1] || 'marks-account'; const handleSignOut = async () => { try { await signOut(); toast.success("Signed out successfully"); router.push("/auth"); } catch (error: any) { toast.error(error.message); } }; return (
{/* Vib'n Logo */} onSectionChange('projects')} className="flex h-14 w-16 items-center justify-center border-b" > Vib'n
{/* Navigation Items */}
{navItems.map((item) => { const Icon = item.icon; const fullHref = `/${workspace}${item.href}`; const isActive = activeSection === item.id || pathname?.includes(item.href); return ( onSectionChange(item.id)} className={cn( "flex flex-col items-center gap-1 w-full py-2 px-2 transition-all relative", isActive ? "text-primary bg-primary/5" : "text-muted-foreground hover:text-foreground hover:bg-accent" )} > {item.label} {isActive && (
)} ); })}
{/* Bottom Items */}
Settings
); }