fix: fallback fresh slots when all availableSlots passed + SW v57

This commit is contained in:
root 2026-07-03 13:37:42 +00:00
parent a74a5242b8
commit 8ade6a6ff3
2 changed files with 18 additions and 3 deletions

View File

@ -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) => {

View File

@ -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 = ({