diff --git a/.replit b/.replit index e8328f8..c50bc15 100644 --- a/.replit +++ b/.replit @@ -31,10 +31,6 @@ externalPort = 3002 localPort = 43267 externalPort = 3003 -[[ports]] -localPort = 45679 -externalPort = 4200 - [env] PORT = "5000" diff --git a/client/src/pages/general-planning.tsx b/client/src/pages/general-planning.tsx index 7de2945..db0b198 100644 --- a/client/src/pages/general-planning.tsx +++ b/client/src/pages/general-planning.tsx @@ -108,7 +108,7 @@ export default function GeneralPlanning() { // Mutation per creare turno multi-giorno const createShiftMutation = useMutation({ mutationFn: async (data: { siteId: string; startDate: string; days: number; guardId: string }) => { - return apiRequest("/api/general-planning/shifts", "POST", data); + return apiRequest("POST", "/api/general-planning/shifts", data); }, onSuccess: () => { // Invalida cache planning generale diff --git a/replit.md b/replit.md index 4060acd..a30d0b4 100644 --- a/replit.md +++ b/replit.md @@ -54,15 +54,23 @@ The database includes core tables for `users`, `guards`, `certifications`, `site - Table cells display: assigned guards with hours, vehicles, missing guards badge (if any), shift count, total hours - Interactive cells with click handler opening detail dialog - Dialog shows: shift count, total hours, guard list with hours and badge numbers, vehicle list, missing guards warning with explanation + - **Direct Shift Creation from Dialog**: Users can now create multi-day shifts directly from the Planning Generale dialog: + - Select guard from dropdown showing name + weekly available hours (max 45h - assigned hours) + - Specify number of consecutive days (1-7) + - Backend endpoint `POST /api/general-planning/shifts` with atomic transaction using `db.transaction()` - all shifts created or none (rollback on error) + - Validates contract dates, site and guard existence before transaction + - Automatically creates shifts spanning multiple days with correct time ranges from site service schedule + - TanStack Query mutation with cache invalidation for real-time planning grid updates - "Modifica in Pianificazione Operativa" button in dialog navigates to operational planning page with pre-filled date/location parameters - Week navigation (previous/next week) with location selector - Operational planning page now supports query parameters (`?date=YYYY-MM-DD&location=sede`) for seamless integration -**Recent Bug Fixes (October 17, 2025)**: +**Recent Bug Fixes (October 17-18, 2025)**: - **Operational Planning Date Handling**: Fixed date sanitization in `/api/operational-planning/uncovered-sites` and `/api/operational-planning/availability` endpoints to handle malformed date inputs (e.g., "2025-10-17/2025-10-17"). Both endpoints now validate dates using `parseISO`/`isValid` and return 400 for invalid formats. - **Checkbox Event Propagation**: Fixed double-toggle bug in operational planning resource selection by wrapping vehicle and guard checkboxes in `
e.stopPropagation()}>` to prevent Card onClick from firing when clicking checkboxes. - **Multi-Sede Resource Isolation**: Fixed critical bug where resources from different sedi were incorrectly marked as unavailable due to global shift queries. Now both availability and uncovered-sites endpoints filter shifts by location using JOIN with sites table. - **QueryKey Cache Invalidation**: Fixed queryKey structure from single-string to hierarchical array with custom queryFn to enable targeted cache invalidation by location and date while preventing URL concatenation errors. +- **apiRequest Parameter Order (October 18, 2025)**: Fixed inverted parameters bug in Planning Generale shift creation mutation. Changed `apiRequest(url, method, data)` to correct signature `apiRequest(method, url, data)` matching queryClient.ts function definition. ### API Endpoints Comprehensive RESTful API endpoints are provided for Authentication, Users, Guards, Sites, Shifts, and Notifications, supporting full CRUD operations with role-based access control.