Add ability to create multi-day shifts from planning interface
Update client to allow creating multi-day shifts directly from the General Planning dialog, and fix the `apiRequest` parameter order in the mutation. 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/zGfvPmX
This commit is contained in:
parent
eb3e6c4aac
commit
8068a808de
4
.replit
4
.replit
@ -31,10 +31,6 @@ externalPort = 3002
|
||||
localPort = 43267
|
||||
externalPort = 3003
|
||||
|
||||
[[ports]]
|
||||
localPort = 45679
|
||||
externalPort = 4200
|
||||
|
||||
[env]
|
||||
PORT = "5000"
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
10
replit.md
10
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 `<div onClick={e => 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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user