diff --git a/replit.md b/replit.md index c1edd98..dc8928c 100644 --- a/replit.md +++ b/replit.md @@ -19,6 +19,7 @@ VigilanzaTurni is a professional 24/7 shift management system for security compa - **Autenticazione**: Replit Auth (OIDC) - **State Management**: TanStack Query v5 - **Routing**: Wouter +- **Maps**: Leaflet + react-leaflet + OpenStreetMap tiles ### Design System - **Font Principale**: Inter (sans-serif) @@ -34,7 +35,7 @@ The database includes tables for `users`, `guards`, `certifications`, `sites`, ` - **Multi-Sede Operational Planning**: Location-first approach for shift planning, filtering sites, guards, and vehicles by selected branch. - **Service Type Classification**: Service types are classified as "fisso" (fixed posts) or "mobile" (patrols, inspections) to route sites to appropriate planning modules (Planning Fissi, Planning Mobile). - **Planning Fissi**: Weekly planning grid showing all sites with active contracts, allowing direct shift creation for multiple days with guard availability checks. -- **Planning Mobile**: Dedicated guard-centric interface for mobile services, displaying guard availability and hours for mobile-classified sites. Includes a map placeholder for future integration. +- **Planning Mobile**: Dedicated guard-centric interface for mobile services, displaying guard availability and hours for mobile-classified sites. Includes interactive Leaflet map showing sites with GPS coordinates and automatic re-centering based on selected location. - **Customer Management**: Full CRUD operations for customers with comprehensive details. - **Customer-Centric Reports**: New reports aggregating data by customer, replacing site-based billing, with specific counters for fixed posts (hours), patrols (passages), inspections, and interventions. CSV export is supported. - **Dashboard Operativa**: Live KPIs and real-time shift status. @@ -53,7 +54,23 @@ The database includes tables for `users`, `guards`, `certifications`, `sites`, ` To prevent timezone-related bugs, especially when assigning shifts, dates should always be constructed from components (`new Date(year, month-1, day)`) and never parsed from ISO strings directly using `parseISO()` or `new Date(string ISO)`. Date validation should use regex instead of `parseISO()`. ## Recent Changes (October 2025) -### Sites Form Fix - ServiceTypeId Integration +### Planning Mobile - Leaflet Map Integration (October 23, 2025) +- **Issue**: Planning Mobile page had errors in backend endpoints and lacked interactive map functionality +- **Solution**: + - **Backend Fixes**: + - Removed non-existent fields (`city` from sites, `isActive` from guards) from queries + - Changed `innerJoin` to `leftJoin` for service types to handle sites without serviceTypeId + - Fixed `orderBy` syntax (single field instead of multiple) + - Added `hasDriverLicense` filter for guards (mobile services require driving) + - **Map Integration**: + - Implemented Leaflet + react-leaflet with OpenStreetMap tiles (100% free, no API key) + - Interactive markers for sites with GPS coordinates and classification="mobile" + - Popup details showing site name, address, and service type + - Automatic re-centering via `key={selectedLocation}` forcing MapContainer remount + - Graceful fallback for sites without coordinates +- **Impact**: Planning Mobile now fully functional with interactive map for patrol/inspection route planning + +### Sites Form Fix - ServiceTypeId Integration (October 2025) - **Issue**: Sites form used hardcoded `shiftType` enum values instead of dynamic service types from the database - **Solution**: - Changed Sites form to use `serviceTypeId` (FK to `service_types.id`) instead of deprecated `shiftType` field @@ -70,4 +87,5 @@ To prevent timezone-related bugs, especially when assigning shifts, dates should - **Zod**: For schema validation. - **TanStack Query**: For data fetching and state management. - **Wouter**: For client-side routing. -- **date-fns**: For date manipulation and formatting. \ No newline at end of file +- **date-fns**: For date manipulation and formatting. +- **Leaflet**: Interactive map library with react-leaflet bindings and OpenStreetMap tiles (free). \ No newline at end of file