fix: fallback fresh slots when all availableSlots passed + SW v57
This commit is contained in:
parent
a74a5242b8
commit
8ade6a6ff3
|
|
@ -1,8 +1,8 @@
|
||||||
const isLocalhost = self.location.hostname === "localhost" || self.location.hostname === "127.0.0.1";
|
const isLocalhost = self.location.hostname === "localhost" || self.location.hostname === "127.0.0.1";
|
||||||
|
|
||||||
if (!isLocalhost) {
|
if (!isLocalhost) {
|
||||||
const STATIC_CACHE = "construction-delivery-static-v56";
|
const STATIC_CACHE = "construction-delivery-static-v57";
|
||||||
const RUNTIME_CACHE = "construction-delivery-runtime-v56";
|
const RUNTIME_CACHE = "construction-delivery-runtime-v57";
|
||||||
const APP_SHELL_URLS = ["/", "/index.html", "/manifest.webmanifest", "/icons/icon-192.png", "/icons/icon-512.png"];
|
const APP_SHELL_URLS = ["/", "/index.html", "/manifest.webmanifest", "/icons/icon-192.png", "/icons/icon-512.png"];
|
||||||
|
|
||||||
self.addEventListener("install", (event) => {
|
self.addEventListener("install", (event) => {
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ export const groupSlotsFromInvitation = (invitation, referenceDate = new Date())
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return rawSlots
|
const result = rawSlots
|
||||||
.map((raw, index) => {
|
.map((raw, index) => {
|
||||||
if (typeof raw === "string") {
|
if (typeof raw === "string") {
|
||||||
const parts = raw.split(",");
|
const parts = raw.split(",");
|
||||||
|
|
@ -167,6 +167,21 @@ export const groupSlotsFromInvitation = (invitation, referenceDate = new Date())
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.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 = ({
|
export const buildDeliveryConfirmationPayload = ({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue