diff --git a/frontend/src/lib/lunchProtection.ts b/frontend/src/lib/lunchProtection.ts index c58dfa4..701b183 100644 --- a/frontend/src/lib/lunchProtection.ts +++ b/frontend/src/lib/lunchProtection.ts @@ -217,15 +217,29 @@ export function getLunchProtectionForSlots( showWarning: false, warningMessage: 'This booking would leave no lunch break (minimum 30 minutes required).' }); + } else if (gapWith < 60) { + const gapsWithout = findAllLunchGaps(windowStart, windowEnd, existingBookings); + const gapWithout = gapsWithout[0] ?? 0; + if (gapWith < gapWithout) { + results.set(slotStartStr, { + isBlocked: false, + showWarning: true, + warningMessage: `This booking would reduce lunch break to ${gapWith} minutes.` + }); + } } } else { if (gapWith < 60) { - results.set(slotStartStr, { - isBlocked: true, - showWarning: false, - warningMessage: - 'This booking would leave insufficient lunch break (minimum 1 hour required).' - }); + const gapsWithout = findAllLunchGaps(windowStart, windowEnd, existingBookings); + const gapWithout = gapsWithout[0] ?? 0; + if (gapWith < gapWithout) { + results.set(slotStartStr, { + isBlocked: true, + showWarning: false, + warningMessage: + 'This booking would leave insufficient lunch break (minimum 1 hour required).' + }); + } } } }