Floorplan Components
Overview
The Warehouse Floor Plan module provides SVG-based zone layout visualization with real-time driver overlay.
Components
FloorplanEditor (Admin Only)
Admin-only floor plan editor with full editing capabilities.
Features:
- SVG upload/import
- Canvas editor with pan & zoom
- Draw rectangular zones (drag to draw)
- Select zone tool (select + move + resize)
- Color picker + label input for zones
- Snap-to-grid toggle
- Undo/Redo basic (stack of changes)
- Save button with debounced autosave
- Zone list panel
- Heatmap toggle
- Driver overlay toggle (real-time markers)
- Export/Import JSON
Location: src/pages/admin/FloorplanEditor.tsx
FloorplanViewer (Read-Only)
Read-only viewer for workers and admins.
Features:
- Load floorplan + zones (read-only)
- Pan & Zoom
- Zone highlighting on hover/click
- Heatmap toggle (read-only)
- Driver overlay toggle
- Pick & Pack integration:
- Highlight route for current pick list
- Show "Your next zone: Z07" with blinking highlight
- No editing capabilities
Location: src/pages/warehouse/FloorplanViewer.tsx
Backend Functions
lib/floorplan.ts
Core floorplan management functions:
parseSvg()- Extract width, height, viewBox from SVGnormalizeCoordinates()- Normalize coordinates to viewBox unitssanitizeSvg()- Remove scripts/styles (XSS protection)createFloorplan()- Create new floorplanupdateFloorplan()- Update existing floorplancreateZoneFromRect()- Create zone shape from rectangleupdateZoneShape()- Update zone shape propertiesdeleteZoneShape()- Delete zone shapegetFloorplanWithZones()- Get floorplan with all zonescomputeHeatmap()- Compute heatmap data from analyticsmapGeoToSvg()- Map GPS coordinates to SVG (optional)
Security
- SVG content sanitization using
sanitize-html - Tenant isolation via RLS policies
- Admin-only editing (workers read-only)
- Rate limiting on save operations
Integration
- Zones: Links to existing
zonestable - Analytics: Heatmap computed from analytics data
- Driver Locations: Real-time GPS overlay
- Pick & Pack: Route visualization on floor plan
Permissions
- Admin: Full access (create, read, update, delete)
- Worker: Read-only access (viewer)
- Driver: No access
Database Tables
floorplans- Master floor plan recordsfloorplan_zones- Zone shapes on floor plans
See Database Schema for details.