From c023501f57d54c2ac4ebad193285190a7d8681f4 Mon Sep 17 00:00:00 2001 From: donpat1to Date: Tue, 21 Oct 2025 00:51:39 +0200 Subject: [PATCH] updated every file for database changes; starting scheduling debugging --- backend/src/services/SchedulingService.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/backend/src/services/SchedulingService.ts b/backend/src/services/SchedulingService.ts index e058eb1..15c8d6a 100644 --- a/backend/src/services/SchedulingService.ts +++ b/backend/src/services/SchedulingService.ts @@ -97,17 +97,16 @@ export class SchedulingService { const currentDate = new Date(startDate); currentDate.setDate(startDate.getDate() + dayOffset); - const dayOfWeek = currentDate.getDay() === 0 ? 7 : currentDate.getDay(); + const dayOfWeek = currentDate.getDay() === 0 ? 7 : currentDate.getDay(); // Convert Sunday from 0 to 7 const dayShifts = shiftPlan.shifts.filter(shift => shift.dayOfWeek === dayOfWeek); dayShifts.forEach(shift => { - // ✅ CRITICAL FIX: Use consistent shift ID format that matches availability lookup - const shiftId = `shift_${dayOfWeek}_${shift.timeSlotId}`; - const dateStr = currentDate.toISOString().split('T')[0]; + // ✅ Use day-of-week pattern instead of date-based pattern + const shiftId = `${shift.id}`; shifts.push({ - id: shiftId, // This will match what availabilities are looking for - date: dateStr, + id: shiftId, // This matches what frontend expects + date: currentDate.toISOString().split('T')[0], timeSlotId: shift.timeSlotId, requiredEmployees: shift.requiredEmployees, minWorkers: 1, @@ -115,7 +114,7 @@ export class SchedulingService { isPriority: false }); - console.log(`✅ Generated shift: ${shiftId} for date ${dateStr}, day ${dayOfWeek}, timeSlot ${shift.timeSlotId}`); + console.log(`✅ Generated shift: ${shiftId} for day ${dayOfWeek}, timeSlot ${shift.timeSlotId}`); }); }