From 7c8fd94fcbac278500adb6e80ace376ac09ccb14 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Fri, 10 Jul 2026 21:10:00 +0100 Subject: [PATCH] fix: restore admin lunch warning tier (30-60min) with gap-worsening comparison --- frontend/src/lib/lunchProtection.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) 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).' + }); + } } } }