import { useDrawingStore } from '../../stores/drawingStore'; import type { DrawingTool } from '../../types/mapItem'; import { CABLE_COLORS, CABLE_LABELS } from '../../types/mapItem'; interface ToolbarProps { mapId: string; readOnly?: boolean; } interface ToolButton { id: DrawingTool; label: string; icon: string; color?: string; description: string; } const SELECT_TOOL: ToolButton = { id: 'select', label: 'Select', icon: '👆', description: 'Select and edit items', }; const CONNECTION_TOOLS: ToolButton[] = [ { id: 'wireless_mesh', label: 'Wireless', icon: 'wireless', color: '#10B981', description: 'Wireless Mesh Link', }, { id: 'fiber', label: 'Fiber', icon: '━', color: CABLE_COLORS.fiber, description: CABLE_LABELS.fiber, }, { id: 'cat6', label: 'Cat6', icon: '━', color: CABLE_COLORS.cat6, description: CABLE_LABELS.cat6, }, { id: 'cat6_poe', label: 'Cat6 PoE', icon: '━', color: CABLE_COLORS.cat6_poe, description: CABLE_LABELS.cat6_poe, }, ]; const DEVICE_TOOLS: ToolButton[] = [ { id: 'switch', label: 'Switch', icon: 'switch', description: 'Network Switch', }, { id: 'indoor_ap', label: 'Indoor AP', icon: 'indoor_ap', description: 'Indoor Access Point', }, { id: 'outdoor_ap', label: 'Outdoor AP', icon: 'outdoor_ap', description: 'Outdoor Access Point', }, ]; export function Toolbar({ mapId, readOnly = false }: ToolbarProps) { const { activeTool, setActiveTool } = useDrawingStore(); const renderIcon = (tool: ToolButton, isDisabled: boolean) => { if (tool.icon === 'wireless') { return ( ); } if (tool.icon === 'switch') { return ( ); } if (tool.icon === 'indoor_ap') { return ( ); } if (tool.icon === 'outdoor_ap') { return ( ); } return ( {tool.icon} ); }; const renderToolButton = (tool: ToolButton) => { const isDisabled = readOnly && tool.id !== 'select'; return ( ); }; return (
{/* Read-only indicator */} {readOnly && (
Read-Only Mode
)} {/* Tools section header */}

Tools

{/* Select tool */} {renderToolButton(SELECT_TOOL)}
{/* Connections section */}

Connections

{CONNECTION_TOOLS.map(renderToolButton)}
{/* Devices section */}

Devices

{DEVICE_TOOLS.map(renderToolButton)}
); }