import { useRef, useState } from "react"; import { Button } from "./ui/button"; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "./ui/dialog"; import { Input } from "./ui/input"; interface Board { id: string; name: string; description?: string | null; } interface BoardSwitcherProps { boards: Board[]; activeBoardId: string | null; onSelect: (boardId: string) => void; onCreate: (name: string, type: "dev" | "ops") => void; onClose: () => void; } export function BoardSwitcher({ boards, activeBoardId, onSelect, onCreate, onClose }: BoardSwitcherProps) { const [newName, setNewName] = useState(""); const [newType, setNewType] = useState<"dev" | "ops">("dev"); const [creating, setCreating] = useState(false); const inputRef = useRef(null); function handleCreate() { const name = newName.trim(); if (!name) return; onCreate(name, newType); setNewName(""); setNewType("dev"); setCreating(false); } return ( { if (!open) onClose(); }} > Switch Board Select a board to switch to {/* Board list */}
{boards.map((b) => { const isActive = b.id === activeBoardId; return ( ); })} {boards.length === 0 && (

No boards yet

)}
{/* Footer: create */}
{creating ? (
setNewName(e.target.value)} onKeyDown={(e) => { if (e.key === "Enter") handleCreate(); if (e.key === "Escape") { setCreating(false); setNewName(""); } }} placeholder="Board name" autoFocus />
{(["dev", "ops"] as const).map((t) => ( ))}
) : ( )}
); }