From f05f05ca571eb8735a10848f224f0013ab9607fa Mon Sep 17 00:00:00 2001 From: marco370 <48531002-marco370@users.noreply.replit.com> Date: Thu, 23 Oct 2025 14:37:33 +0000 Subject: [PATCH] Improve map interactions for planning and guard assignment Fix geocoding bug, implement map zooming to site, allow guard assignment to sites, and enable patrol route sequencing via map marker clicks. Replit-Commit-Author: Agent Replit-Commit-Session-Id: e5565357-90e1-419f-b9a8-6ee8394636df Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/6d543d2c-20b9-4ea6-93fe-70fe9b1d9f80/e5565357-90e1-419f-b9a8-6ee8394636df/ZaT6tFl --- .replit | 6 +----- replit.md | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.replit b/.replit index 9b52848..75d108a 100644 --- a/.replit +++ b/.replit @@ -21,7 +21,7 @@ externalPort = 3001 [[ports]] localPort = 41295 -externalPort = 6000 +externalPort = 5173 [[ports]] localPort = 41343 @@ -43,10 +43,6 @@ externalPort = 5000 localPort = 43267 externalPort = 3003 -[[ports]] -localPort = 45047 -externalPort = 5173 - [env] PORT = "5000" diff --git a/replit.md b/replit.md index e7cd54f..cf41ac5 100644 --- a/replit.md +++ b/replit.md @@ -86,6 +86,31 @@ To prevent timezone-related bugs, especially when assigning shifts, dates should - Graceful fallback for sites without coordinates - **Impact**: Planning Mobile now fully functional with interactive map for patrol/inspection route planning +### Planning Mobile - Interactive Features (October 23, 2025) +- **Issue**: Planning Mobile needed interactive map controls and patrol route sequencing workflow +- **Critical Bug Fix - Geocoding**: + - **Problem**: Toast showed "Indirizzo: undefined" when geocoding sites + - **Root Cause**: `apiRequest()` returns Response object, not parsed JSON + - **Fix**: Added `const result = await response.json()` after apiRequest in both handleGeocode() and handleGeocodeEdit() + - **Impact**: Geocoding now correctly displays full address from Nominatim (e.g., "Via Tiburtina, Roma, Lazio, Italia") +- **New Features**: + - **Zoom-to-Site**: + - MapController component with useMap() hook for programmatic map control + - Navigation button on each site card triggers flyTo() animation (zoom level 16) + - Toast feedback: "Mappa centrata - Visualizzazione di [nome sito]" + - **Guard Assignment**: + - "Assegna Guardia" button on site cards + - Validates guard selection from dropdown + - Toast feedback: "[Sito] assegnato a [Nome Cognome Guardia]" + - **Patrol Route Sequencing**: + - Click markers on map to build patrol route sequence + - Visual feedback: Green "Tappa N" badges on markers and site cards + - Dedicated UI section showing route in construction with numbered sequence + - Remove/clear/save route controls + - Auto-reset route when changing guard or location + - **Note**: Backend persistence (save to database) not yet implemented - marked as TODO for future development +- **Impact**: Operators can now interact with the map, assign guards to sites, and visually plan patrol routes by clicking sites in sequence + ### Sites Form Fix - ServiceTypeId Integration (October 2025) - **Issue**: Sites form used hardcoded `shiftType` enum values instead of dynamic service types from the database - **Solution**: