'use client'; import { IconCheck, IconChevronDown } from '@tabler/icons-react'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@kandev/ui/dropdown-menu'; import { cn } from '@/lib/utils'; type Workspace = { id: string; name: string; }; type WorkspaceSwitcherProps = { workspaces: Workspace[]; activeWorkspaceId: string | null; onSelect: (workspaceId: string) => void; }; export function WorkspaceSwitcher({ workspaces, activeWorkspaceId, onSelect, }: WorkspaceSwitcherProps) { const selectedWorkspace = workspaces.find((w) => w.id === activeWorkspaceId); // If only one workspace, show just the name without dropdown if (workspaces.length <= 1) { return ( {selectedWorkspace?.name || 'Workspace'} ); } return ( {workspaces.map((workspace) => ( onSelect(workspace.id)} className={cn( 'justify-between', activeWorkspaceId === workspace.id && 'bg-foreground/10' )} > {workspace.name} {activeWorkspaceId === workspace.id && ( )} ))} ); }