From 8ade6a6ff3a903ab9923b61dc9f3636bce9a1abb Mon Sep 17 00:00:00 2001 From: root Date: Fri, 3 Jul 2026 13:37:42 +0000 Subject: [PATCH] fix: fallback fresh slots when all availableSlots passed + SW v57 --- public/service-worker.js | 4 ++-- src/pages/ClientDeliveryPage.jsx | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/public/service-worker.js b/public/service-worker.js index 9c2ea0f..62336ee 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,8 +1,8 @@ const isLocalhost = self.location.hostname === "localhost" || self.location.hostname === "127.0.0.1"; if (!isLocalhost) { - const STATIC_CACHE = "construction-delivery-static-v56"; - const RUNTIME_CACHE = "construction-delivery-runtime-v56"; + const STATIC_CACHE = "construction-delivery-static-v57"; + const RUNTIME_CACHE = "construction-delivery-runtime-v57"; const APP_SHELL_URLS = ["/", "/index.html", "/manifest.webmanifest", "/icons/icon-192.png", "/icons/icon-512.png"]; self.addEventListener("install", (event) => { diff --git a/src/pages/ClientDeliveryPage.jsx b/src/pages/ClientDeliveryPage.jsx index 6516198..c7ca09a 100644 --- a/src/pages/ClientDeliveryPage.jsx +++ b/src/pages/ClientDeliveryPage.jsx @@ -118,7 +118,7 @@ export const groupSlotsFromInvitation = (invitation, referenceDate = new Date()) ]; } - return rawSlots + const result = rawSlots .map((raw, index) => { if (typeof raw === "string") { const parts = raw.split(","); @@ -167,6 +167,21 @@ export const groupSlotsFromInvitation = (invitation, referenceDate = new Date()) return null; }) .filter(Boolean); + + // If all rawSlots were filtered out (dates passed), generate fresh slots + if (!result.length && rawSlots.length) { + const todayKey = getBusinessTodayKey(referenceDate); + const firstWorkday = isAllowedDeliveryDay(todayKey) ? todayKey : getNextDeliveryWorkdayKey(todayKey); + const secondWorkday = getNextDeliveryWorkdayKey(firstWorkday); + return [ + { id: `slot-${firstWorkday}-first`, date: firstWorkday, time: "Первая половина дня" }, + { id: `slot-${firstWorkday}-second`, date: firstWorkday, time: "Вторая половина дня" }, + { id: `slot-${secondWorkday}-first`, date: secondWorkday, time: "Первая половина дня" }, + { id: `slot-${secondWorkday}-second`, date: secondWorkday, time: "Вторая половина дня" }, + ].filter((s) => s.date); + } + + return result; }; export const buildDeliveryConfirmationPayload = ({