@ancon/wildcat-utils 1.43.0-timezone-refactor.8 → 1.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_baseIsEqual-39cef2eb.mjs +530 -0
- package/_baseIsEqual-b3df9240.js +1 -0
- package/_baseIteratee-13e892b8.mjs +151 -0
- package/_baseIteratee-be26bb18.js +1 -0
- package/card/getScannedWalletReadingInfo.d.ts +2 -2
- package/card/getScannedWalletReadingInfo.js +1 -1
- package/card/getScannedWalletReadingInfo.mjs +6 -6
- package/checkout/getCheckoutOrderStatusTexts.js +1 -1
- package/checkout/getCheckoutOrderStatusTexts.mjs +5 -7
- package/checkout/getCheckoutPenguinLockersMetaData.js +1 -1
- package/checkout/getCheckoutPenguinLockersMetaData.mjs +2 -2
- package/checkout/index.js +1 -1
- package/checkout/index.mjs +47 -49
- package/checkout/isCheckoutItemsAreEqual.js +1 -1
- package/checkout/isCheckoutItemsAreEqual.mjs +13 -14
- package/currency/getFormattedCurrency.d.ts +15 -0
- package/currency/getFormattedCurrency.js +1 -1
- package/currency/getFormattedCurrency.mjs +25 -10
- package/index.d.ts +1 -2
- package/index.js +1 -1
- package/index.mjs +237 -255
- package/license/getLicenseUIState.d.ts +1 -1
- package/license/getLicenseUIState.js +1 -1
- package/license/getLicenseUIState.mjs +30 -11
- package/logger/index.js +1 -1
- package/logger/index.mjs +7 -8
- package/logger/pascalCaseFormatter.js +1 -1
- package/logger/pascalCaseFormatter.mjs +27 -21
- package/order/getCheckOrderItemsMappedByTicketItemStatus.js +1 -1
- package/order/getCheckOrderItemsMappedByTicketItemStatus.mjs +13 -15
- package/order/getCheckOrderMinimumStatusTicketItem.js +1 -1
- package/order/getCheckOrderMinimumStatusTicketItem.mjs +17 -19
- package/order/index.js +1 -1
- package/order/index.mjs +9 -11
- package/outlet/constants.d.ts +1 -0
- package/outlet/constants.js +1 -1
- package/outlet/constants.mjs +4 -3
- package/outlet/getExpressAvailableOrderFormats.js +1 -1
- package/outlet/getExpressAvailableOrderFormats.mjs +26 -27
- package/outlet/getExpressNextAvailabilityShiftTime.d.ts +2 -2
- package/outlet/getExpressNextAvailabilityShiftTime.js +1 -1
- package/outlet/getExpressNextAvailabilityShiftTime.mjs +18 -19
- package/outlet/getExpressServiceIntervalEnd.d.ts +2 -2
- package/outlet/getExpressServiceIntervalEnd.js +1 -1
- package/outlet/getExpressServiceIntervalEnd.mjs +9 -7
- package/outlet/getExpressServiceIntervalStart.d.ts +2 -2
- package/outlet/getExpressServiceIntervalStart.js +1 -1
- package/outlet/getExpressServiceIntervalStart.mjs +9 -7
- package/outlet/getListOutletOpeningHoursTable.d.ts +1 -1
- package/outlet/getListOutletOpeningHoursTable.js +1 -1
- package/outlet/getListOutletOpeningHoursTable.mjs +150 -135
- package/outlet/getMomentFromDateAndTimeString.js +1 -1
- package/outlet/getMomentFromDateAndTimeString.mjs +1 -1
- package/outlet/getOutletActiveOpeningInterval.d.ts +2 -2
- package/outlet/getOutletActiveOpeningInterval.js +1 -1
- package/outlet/getOutletActiveOpeningInterval.mjs +12 -15
- package/outlet/getOutletAvailabilityInfo.js +1 -1
- package/outlet/getOutletAvailabilityInfo.mjs +25 -23
- package/outlet/getOutletCurrentActiveOperatingHour.js +1 -1
- package/outlet/getOutletCurrentActiveOperatingHour.mjs +15 -16
- package/outlet/getOutletCurrentAvailabilityInfo.js +1 -1
- package/outlet/getOutletCurrentAvailabilityInfo.mjs +26 -27
- package/outlet/getOutletCurrentClosingTimeText.js +1 -1
- package/outlet/getOutletCurrentClosingTimeText.mjs +10 -14
- package/outlet/getOutletDeliveryFee.js +1 -1
- package/outlet/getOutletDeliveryFee.mjs +5 -5
- package/outlet/getOutletFormattedAddress.d.ts +1 -9
- package/outlet/getOutletFormattedAddress.js +1 -1
- package/outlet/getOutletFormattedAddress.mjs +4 -9
- package/outlet/getOutletNextOpeningTagInformation.js +1 -1
- package/outlet/getOutletNextOpeningTagInformation.mjs +7 -8
- package/outlet/getOutletNextOpeningTimeText.js +1 -1
- package/outlet/getOutletNextOpeningTimeText.mjs +8 -10
- package/outlet/getOutletNextReadyToOrderTime.js +1 -1
- package/outlet/getOutletNextReadyToOrderTime.mjs +29 -21
- package/outlet/getOutletNextServiceTimeOffset.d.ts +11 -0
- package/outlet/getOutletNextServiceTimeOffset.js +1 -0
- package/outlet/getOutletNextServiceTimeOffset.mjs +10 -0
- package/outlet/getOutletPickerTimesForDay.js +1 -1
- package/outlet/getOutletPickerTimesForDay.mjs +38 -36
- package/outlet/getOutletPickerTimesForWeek.js +1 -1
- package/outlet/getOutletPickerTimesForWeek.mjs +2 -2
- package/outlet/getOutletTagInformation.d.ts +1 -1
- package/outlet/getOutletTagInformation.js +1 -1
- package/outlet/getOutletTagInformation.mjs +70 -69
- package/outlet/getOutletTodayOpeningTimes.js +1 -1
- package/outlet/getOutletTodayOpeningTimes.mjs +39 -43
- package/outlet/getPartitionedOutletsList.js +1 -1
- package/outlet/getPartitionedOutletsList.mjs +4 -4
- package/outlet/getPickerIntervalsForDay.js +1 -1
- package/outlet/getPickerIntervalsForDay.mjs +12 -20
- package/outlet/getServiceIntervalEnd.d.ts +1 -1
- package/outlet/getServiceIntervalEnd.js +1 -1
- package/outlet/getServiceIntervalEnd.mjs +10 -12
- package/outlet/getServiceIntervalRange.d.ts +2 -1
- package/outlet/getServiceIntervalRange.js +1 -1
- package/outlet/getServiceIntervalRange.mjs +12 -8
- package/outlet/getServiceIntervalStart.d.ts +1 -1
- package/outlet/getServiceIntervalStart.js +1 -1
- package/outlet/getServiceIntervalStart.mjs +7 -6
- package/outlet/getServiceIntervalsForOrderFormat.d.ts +8 -7
- package/outlet/getStructuredOutletAddress.js +1 -1
- package/outlet/getStructuredOutletAddress.mjs +7 -7
- package/outlet/index.d.ts +2 -1
- package/outlet/index.js +1 -1
- package/outlet/index.mjs +68 -71
- package/outlet/searchNextOpeningMoment.d.ts +1 -1
- package/outlet/searchNextOpeningMoment.js +1 -1
- package/outlet/searchNextOpeningMoment.mjs +56 -49
- package/outlet/serviceDateTimesFromOpeningHours.d.ts +5 -3
- package/outlet/serviceDateTimesFromOpeningHours.js +1 -1
- package/outlet/serviceDateTimesFromOpeningHours.mjs +27 -342
- package/outlet/types.d.ts +2 -0
- package/package.json +16 -21
- package/quantity/getFormattedQuantity.d.ts +24 -0
- package/quantity/getFormattedQuantity.js +1 -0
- package/quantity/getFormattedQuantity.mjs +30 -0
- package/quantity/index.d.ts +2 -0
- package/quantity/index.js +1 -0
- package/quantity/index.mjs +4 -0
- package/time/getEndTimeSpanOfTimePeriod.js +1 -1
- package/time/getEndTimeSpanOfTimePeriod.mjs +9 -5
- package/toString-425512fc.js +1 -0
- package/{toString-3b91b335.mjs → toString-e631a957.mjs} +11 -12
- package/_baseIsEqual-12d01a44.mjs +0 -169
- package/_baseIsEqual-bcac9024.js +0 -1
- package/_baseIteratee-075c204c.js +0 -1
- package/_baseIteratee-4c4d0995.mjs +0 -97
- package/_baseSlice-4d543985.mjs +0 -10
- package/_baseSlice-e1b41ceb.js +0 -1
- package/_getTag-4e44633b.mjs +0 -382
- package/_getTag-b8923c48.js +0 -1
- package/date/createLocalTimezoneDate.d.ts +0 -8
- package/date/createLocalTimezoneDate.js +0 -1
- package/date/createLocalTimezoneDate.mjs +0 -8
- package/date/createLocalTimezoneMoment.d.ts +0 -9
- package/date/createLocalTimezoneMoment.js +0 -1
- package/date/createLocalTimezoneMoment.mjs +0 -8
- package/date/getFormattedUTCDateTime.d.ts +0 -10
- package/date/getFormattedUTCDateTime.js +0 -1
- package/date/getFormattedUTCDateTime.mjs +0 -8
- package/date/index.d.ts +0 -4
- package/date/index.js +0 -1
- package/date/index.mjs +0 -9
- package/identity-1bae7cf8.js +0 -1
- package/identity-6eafe87b.mjs +0 -64
- package/toString-9eae9442.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const F=require("moment"),r=require("@ancon/wildcat-types"),g=require("../shared/isWithinFlag.js"),k=require("../shared/generateId.js");require("react");const l=[{id:r.OrderFormat.EatIn,name:"eatIn"},{id:r.OrderFormat.TakeAway,name:"takeaway"},{id:r.OrderFormat.TableOrder,name:"tableOrder"},{id:r.OrderFormat.Delivery,name:"delivery"},{id:r.OrderFormat.BoxPickup,name:"boxPickup"}];function v(e){const o=F.utc(e).subtract(1,"day").startOf("day"),t=[];for(let s=0,d=o;s<7;s+=1)d=d.clone().add(1,"day").startOf("day"),t.push(d.clone());return t}function W(e){return[...e].sort((o,t)=>o.isoWeekday()-t.isoWeekday())}function I(e){return e.split(":").map(Number)}function T(e,o,t){const[s,d]=I(e.start),[p,m]=I(e.duration),[n,y]=I(t||"00:00:00");if(e.type===r.IntervalType.Interval){let i=o.clone().add(s,"hour").add(d,"minute");const a=i.clone().add(n,"hour").add(y,"minute").date()-o.date();a!==0&&(i=i.subtract(a,"day"));const f=i.clone().add(p,"hour").add(m,"minute");return{id:e.id,start:i.toISOString(),end:f.toISOString()}}if(e.type===r.IntervalType.Exception){const i=F(e.fromDate),u=F(e.toDate);if(o.isBetween(i,u,void 0,"[]")){const a=o.clone().add(s,"hour").add(d,"minute"),f=a.clone().add(p,"hour").add(m,"minute");return{id:e.id,start:a.toISOString(),end:f.toISOString(),reason:e.reason}}return null}throw new Error("Invalid interval type")}function S(e,o,t,s){const d={[r.DayOfWeek.Monday]:1,[r.DayOfWeek.Tuesday]:2,[r.DayOfWeek.Wednesday]:3,[r.DayOfWeek.Thursday]:4,[r.DayOfWeek.Friday]:5,[r.DayOfWeek.Saturday]:6,[r.DayOfWeek.Sunday]:7,[r.DayOfWeek.Everyday]:null};for(let p=0;p<o.length;p+=1){const m=o[p],n=m.isoWeekday(),y=e.dayOfWeek,u=(d[y]??null)===n||y===r.DayOfWeek.Everyday;if(t[n]||(t[n]={isoWeekday:n,key:"",open:[],adjusted:[],closed:[]}),u){const a=T(e,m,s);a&&(t[n].key+=a.id,e.type===r.IntervalType.Interval&&e.state===r.IntervalState.Open?t[n].open.push(a):e.type===r.IntervalType.Interval&&e.state===r.IntervalState.Closed?t[n].closed.push(a):e.type===r.IntervalType.Exception&&e.state===r.IntervalState.Open?t[n].adjusted.push(a):e.type===r.IntervalType.Exception&&e.state===r.IntervalState.Closed&&t[n].closed.push(a))}}}function h(e){switch(e.type){case r.IntervalType.Exception:return k("interval-exception");case r.IntervalType.Interval:return k("interval-normal");default:return k("interval-unknown")}}function D(e){const o=e.reduce((t,s)=>(l.forEach(d=>{g(d.id,s.orderFormats)&&(t[d.id]||(t[d.id]={orderFormat:d,intervals:[]}),t[d.id].intervals.push(...s.intervals.sort((p,m)=>p.dayOfWeek-m.dayOfWeek)))}),t),{});return Object.values(o)}function x(e,o){const t=o.reduce((s,d)=>d<=e?s+1:s,0);return e-t}function M(e){const{mergedTables:o}=e.reduce((t,s,d)=>{const p=t.mergedTables.findIndex(m=>m!==s&&!m.orderFormats.some(n=>s.orderFormats.some(y=>y.id===n.id))&&m.openingHours.every(n=>s.openingHours.some(y=>y.key===n.key))&&s.openingHours.every(n=>m.openingHours.some(y=>y.key===n.key)));if(p>=0){if(t.skipOrderFormats.some(u=>s.orderFormats.every(a=>a.id===u.id)))return t;const n=t.mergedTables[p];t.mergedTables.splice(p,1,{...n,orderFormats:[...s.orderFormats,...n.orderFormats]});const y=n.orderFormats.filter(u=>!t.skipOrderFormats.some(a=>a.id===u.id));y.length>0&&t.skipOrderFormats.push(...y);const i=x(d,[...t.removedIndexes]);return t.mergedTables.splice(i,1),t.removedIndexes.push(d),t}return t},{mergedTables:[...e],removedIndexes:[],skipOrderFormats:[]});return o}function H(e){return e.map(o=>({...o,intervals:o.intervals.map(t=>({...t,id:h(t)}))}))}function E(e,o){const t=D(H(e.serviceDateTimes)),s=v(o),d=W(s),p=t.reduce((i,u)=>(i[u.orderFormat.id]||(i[u.orderFormat.id]={}),u.intervals.reduce((a,f)=>(S(f,d,a,e.timeZoneOffset),a),i[u.orderFormat.id]),i),{}),m={[r.OrderFormat.EatIn]:l[0],[r.OrderFormat.TakeAway]:l[1],[r.OrderFormat.TableOrder]:l[2],[r.OrderFormat.Delivery]:l[3],[r.OrderFormat.BoxPickup]:l[4]},n=Object.entries(p).map(([i,u])=>({orderFormats:[m[Number(i)]],openingHours:Object.entries(u).map(([a,f])=>({isoWeekday:Number(a),key:f.key,open:f.open.sort((O,c)=>O.start.localeCompare(c.start)),adjusted:f.adjusted.sort((O,c)=>O.start.localeCompare(c.start)),closed:f.closed.sort((O,c)=>O.start.localeCompare(c.start))}))}));return M(n).sort((i,u)=>i.orderFormats[0].id-u.orderFormats[0].id)}module.exports=E;
|
|
@@ -1,188 +1,203 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { OrderFormat as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import S from "moment";
|
|
2
|
+
import { OrderFormat as y, DayOfWeek as l, IntervalType as c, IntervalState as g } from "@ancon/wildcat-types";
|
|
3
|
+
import h from "../shared/isWithinFlag.mjs";
|
|
4
|
+
import F from "../shared/generateId.mjs";
|
|
5
5
|
import "react";
|
|
6
|
-
import T from "../time/getTimeSpanParts.mjs";
|
|
7
|
-
import M from "../date/createLocalTimezoneMoment.mjs";
|
|
8
6
|
const k = [
|
|
9
|
-
{ id:
|
|
10
|
-
{ id:
|
|
11
|
-
{ id:
|
|
12
|
-
{ id:
|
|
13
|
-
{ id:
|
|
7
|
+
{ id: y.EatIn, name: "eatIn" },
|
|
8
|
+
{ id: y.TakeAway, name: "takeaway" },
|
|
9
|
+
{ id: y.TableOrder, name: "tableOrder" },
|
|
10
|
+
{ id: y.Delivery, name: "delivery" },
|
|
11
|
+
{ id: y.BoxPickup, name: "boxPickup" }
|
|
14
12
|
];
|
|
15
|
-
function
|
|
16
|
-
const
|
|
17
|
-
for (let n = 0,
|
|
18
|
-
|
|
19
|
-
return
|
|
13
|
+
function v(e) {
|
|
14
|
+
const o = S.utc(e).subtract(1, "day").startOf("day"), t = [];
|
|
15
|
+
for (let n = 0, s = o; n < 7; n += 1)
|
|
16
|
+
s = s.clone().add(1, "day").startOf("day"), t.push(s.clone());
|
|
17
|
+
return t;
|
|
20
18
|
}
|
|
21
|
-
function
|
|
22
|
-
return [...
|
|
19
|
+
function T(e) {
|
|
20
|
+
return [...e].sort((o, t) => o.isoWeekday() - t.isoWeekday());
|
|
23
21
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
function W(e) {
|
|
23
|
+
return e.split(":").map(Number);
|
|
24
|
+
}
|
|
25
|
+
function x(e, o, t) {
|
|
26
|
+
const [n, s] = W(e.start), [m, u] = W(
|
|
27
|
+
e.duration
|
|
28
|
+
), [r, p] = W(t || "00:00:00");
|
|
29
|
+
if (e.type === c.Interval) {
|
|
30
|
+
let a = o.clone().add(n, "hour").add(s, "minute");
|
|
31
|
+
const d = a.clone().add(r, "hour").add(p, "minute").date() - o.date();
|
|
32
|
+
d !== 0 && (a = a.subtract(d, "day"));
|
|
33
|
+
const f = a.clone().add(m, "hour").add(u, "minute");
|
|
31
34
|
return {
|
|
32
|
-
id:
|
|
33
|
-
start:
|
|
34
|
-
end:
|
|
35
|
+
id: e.id,
|
|
36
|
+
start: a.toISOString(),
|
|
37
|
+
end: f.toISOString()
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
|
-
if (
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
40
|
+
if (e.type === c.Exception) {
|
|
41
|
+
const a = S(e.fromDate), i = S(e.toDate);
|
|
42
|
+
if (o.isBetween(a, i, void 0, "[]")) {
|
|
43
|
+
const d = o.clone().add(n, "hour").add(s, "minute"), f = d.clone().add(m, "hour").add(u, "minute");
|
|
41
44
|
return {
|
|
42
|
-
id:
|
|
43
|
-
start:
|
|
44
|
-
end:
|
|
45
|
-
reason:
|
|
45
|
+
id: e.id,
|
|
46
|
+
start: d.toISOString(),
|
|
47
|
+
end: f.toISOString(),
|
|
48
|
+
reason: e.reason
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
51
|
return null;
|
|
49
52
|
}
|
|
50
53
|
throw new Error("Invalid interval type");
|
|
51
54
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
[
|
|
55
|
-
[
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
55
|
+
function M(e, o, t, n) {
|
|
56
|
+
const s = {
|
|
57
|
+
[l.Monday]: 1,
|
|
58
|
+
[l.Tuesday]: 2,
|
|
59
|
+
[l.Wednesday]: 3,
|
|
60
|
+
[l.Thursday]: 4,
|
|
61
|
+
[l.Friday]: 5,
|
|
62
|
+
[l.Saturday]: 6,
|
|
63
|
+
[l.Sunday]: 7,
|
|
64
|
+
[l.Everyday]: null
|
|
62
65
|
};
|
|
63
|
-
for (let
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
isoWeekday:
|
|
66
|
+
for (let m = 0; m < o.length; m += 1) {
|
|
67
|
+
const u = o[m], r = u.isoWeekday(), p = e.dayOfWeek, i = (s[p] ?? null) === r || p === l.Everyday;
|
|
68
|
+
if (t[r] || (t[r] = {
|
|
69
|
+
isoWeekday: r,
|
|
67
70
|
key: "",
|
|
68
71
|
open: [],
|
|
69
72
|
adjusted: [],
|
|
70
73
|
closed: []
|
|
71
|
-
}),
|
|
72
|
-
const d = x(
|
|
73
|
-
|
|
74
|
+
}), i) {
|
|
75
|
+
const d = x(
|
|
76
|
+
e,
|
|
77
|
+
u,
|
|
78
|
+
n
|
|
79
|
+
);
|
|
80
|
+
d && (t[r].key += d.id, e.type === c.Interval && e.state === g.Open ? t[r].open.push(d) : e.type === c.Interval && e.state === g.Closed ? t[r].closed.push(d) : e.type === c.Exception && e.state === g.Open ? t[r].adjusted.push(d) : e.type === c.Exception && e.state === g.Closed && t[r].closed.push(d));
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
|
-
function
|
|
78
|
-
switch (
|
|
79
|
-
case
|
|
80
|
-
return
|
|
81
|
-
case
|
|
82
|
-
return
|
|
84
|
+
function H(e) {
|
|
85
|
+
switch (e.type) {
|
|
86
|
+
case c.Exception:
|
|
87
|
+
return F("interval-exception");
|
|
88
|
+
case c.Interval:
|
|
89
|
+
return F("interval-normal");
|
|
83
90
|
default:
|
|
84
|
-
return
|
|
91
|
+
return F("interval-unknown");
|
|
85
92
|
}
|
|
86
93
|
}
|
|
87
|
-
function E(
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
function E(e) {
|
|
95
|
+
const o = e.reduce(
|
|
96
|
+
(t, n) => (k.forEach((s) => {
|
|
97
|
+
h(s.id, n.orderFormats) && (t[s.id] || (t[s.id] = {
|
|
98
|
+
orderFormat: s,
|
|
99
|
+
intervals: []
|
|
100
|
+
}), t[s.id].intervals.push(
|
|
101
|
+
...n.intervals.sort(
|
|
102
|
+
(m, u) => m.dayOfWeek - u.dayOfWeek
|
|
103
|
+
)
|
|
104
|
+
));
|
|
105
|
+
}), t),
|
|
106
|
+
{}
|
|
107
|
+
);
|
|
108
|
+
return Object.values(o);
|
|
99
109
|
}
|
|
100
|
-
function
|
|
101
|
-
const
|
|
102
|
-
return
|
|
110
|
+
function b(e, o) {
|
|
111
|
+
const t = o.reduce((n, s) => s <= e ? n + 1 : n, 0);
|
|
112
|
+
return e - t;
|
|
103
113
|
}
|
|
104
|
-
function
|
|
105
|
-
const { mergedTables:
|
|
106
|
-
(
|
|
107
|
-
const
|
|
108
|
-
(
|
|
109
|
-
(
|
|
110
|
-
(
|
|
114
|
+
function D(e) {
|
|
115
|
+
const { mergedTables: o } = e.reduce(
|
|
116
|
+
(t, n, s) => {
|
|
117
|
+
const m = t.mergedTables.findIndex(
|
|
118
|
+
(u) => u !== n && !u.orderFormats.some(
|
|
119
|
+
(r) => n.orderFormats.some(
|
|
120
|
+
(p) => p.id === r.id
|
|
111
121
|
)
|
|
112
|
-
) &&
|
|
113
|
-
(
|
|
122
|
+
) && u.openingHours.every(
|
|
123
|
+
(r) => n.openingHours.some((p) => p.key === r.key)
|
|
114
124
|
) && n.openingHours.every(
|
|
115
|
-
(
|
|
125
|
+
(r) => u.openingHours.some((p) => p.key === r.key)
|
|
116
126
|
)
|
|
117
127
|
);
|
|
118
|
-
if (
|
|
119
|
-
if (
|
|
120
|
-
(
|
|
128
|
+
if (m >= 0) {
|
|
129
|
+
if (t.skipOrderFormats.some(
|
|
130
|
+
(i) => n.orderFormats.every((d) => d.id === i.id)
|
|
121
131
|
))
|
|
122
|
-
return
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
...
|
|
126
|
-
orderFormats: [...n.orderFormats, ...
|
|
132
|
+
return t;
|
|
133
|
+
const r = t.mergedTables[m];
|
|
134
|
+
t.mergedTables.splice(m, 1, {
|
|
135
|
+
...r,
|
|
136
|
+
orderFormats: [...n.orderFormats, ...r.orderFormats]
|
|
127
137
|
});
|
|
128
|
-
const
|
|
129
|
-
(
|
|
138
|
+
const p = r.orderFormats.filter(
|
|
139
|
+
(i) => !t.skipOrderFormats.some((d) => d.id === i.id)
|
|
130
140
|
);
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
return
|
|
141
|
+
p.length > 0 && t.skipOrderFormats.push(...p);
|
|
142
|
+
const a = b(s, [...t.removedIndexes]);
|
|
143
|
+
return t.mergedTables.splice(a, 1), t.removedIndexes.push(s), t;
|
|
134
144
|
}
|
|
135
|
-
return
|
|
145
|
+
return t;
|
|
136
146
|
},
|
|
137
|
-
{ mergedTables: [...
|
|
147
|
+
{ mergedTables: [...e], removedIndexes: [], skipOrderFormats: [] }
|
|
138
148
|
);
|
|
139
|
-
return
|
|
149
|
+
return o;
|
|
140
150
|
}
|
|
141
|
-
function
|
|
142
|
-
return
|
|
143
|
-
...
|
|
144
|
-
intervals:
|
|
145
|
-
...
|
|
146
|
-
id:
|
|
151
|
+
function j(e) {
|
|
152
|
+
return e.map((o) => ({
|
|
153
|
+
...o,
|
|
154
|
+
intervals: o.intervals.map((t) => ({
|
|
155
|
+
...t,
|
|
156
|
+
id: H(t)
|
|
147
157
|
}))
|
|
148
158
|
}));
|
|
149
159
|
}
|
|
150
|
-
function
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
), n =
|
|
154
|
-
(
|
|
160
|
+
function R(e, o) {
|
|
161
|
+
const t = E(
|
|
162
|
+
j(e.serviceDateTimes)
|
|
163
|
+
), n = v(o), s = T(n), m = t.reduce(
|
|
164
|
+
(a, i) => (a[i.orderFormat.id] || (a[i.orderFormat.id] = {}), i.intervals.reduce((d, f) => (M(
|
|
165
|
+
f,
|
|
166
|
+
s,
|
|
167
|
+
d,
|
|
168
|
+
e.timeZoneOffset
|
|
169
|
+
), d), a[i.orderFormat.id]), a),
|
|
155
170
|
{}
|
|
156
|
-
),
|
|
157
|
-
[
|
|
158
|
-
[
|
|
159
|
-
[
|
|
160
|
-
[
|
|
161
|
-
[
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
).map(([
|
|
165
|
-
orderFormats: [
|
|
166
|
-
openingHours: Object.entries(
|
|
167
|
-
([
|
|
168
|
-
isoWeekday: Number(
|
|
169
|
-
key:
|
|
170
|
-
open:
|
|
171
|
-
(
|
|
171
|
+
), u = {
|
|
172
|
+
[y.EatIn]: k[0],
|
|
173
|
+
[y.TakeAway]: k[1],
|
|
174
|
+
[y.TableOrder]: k[2],
|
|
175
|
+
[y.Delivery]: k[3],
|
|
176
|
+
[y.BoxPickup]: k[4]
|
|
177
|
+
}, r = Object.entries(
|
|
178
|
+
m
|
|
179
|
+
).map(([a, i]) => ({
|
|
180
|
+
orderFormats: [u[Number(a)]],
|
|
181
|
+
openingHours: Object.entries(i).map(
|
|
182
|
+
([d, f]) => ({
|
|
183
|
+
isoWeekday: Number(d),
|
|
184
|
+
key: f.key,
|
|
185
|
+
open: f.open.sort(
|
|
186
|
+
(O, I) => O.start.localeCompare(I.start)
|
|
172
187
|
),
|
|
173
|
-
adjusted:
|
|
174
|
-
(
|
|
188
|
+
adjusted: f.adjusted.sort(
|
|
189
|
+
(O, I) => O.start.localeCompare(I.start)
|
|
175
190
|
),
|
|
176
|
-
closed:
|
|
177
|
-
(
|
|
191
|
+
closed: f.closed.sort(
|
|
192
|
+
(O, I) => O.start.localeCompare(I.start)
|
|
178
193
|
)
|
|
179
194
|
})
|
|
180
195
|
)
|
|
181
196
|
}));
|
|
182
|
-
return
|
|
183
|
-
(
|
|
197
|
+
return D(r).sort(
|
|
198
|
+
(a, i) => a.orderFormats[0].id - i.orderFormats[0].id
|
|
184
199
|
);
|
|
185
200
|
}
|
|
186
201
|
export {
|
|
187
|
-
|
|
202
|
+
R as default
|
|
188
203
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const u=require("moment");function m(t){const[e,r,n]=t.split(":");return u().utc(!1).startOf("day").set({hour:Number(e),minute:Number(r),second:Number(n),millisecond:0})}function s(t,e){const[r,n,o]=t.split("-");return m(e).year(Number(r)).month(Number(n)-1).date(Number(o))}module.exports=s;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpeningHours, OrderFormat } from '@ancon/wildcat-types';
|
|
2
2
|
import { Moment } from 'moment';
|
|
3
3
|
/**
|
|
4
4
|
* Get the active opening interval for the given outlet opening hours, date and order format
|
|
@@ -8,4 +8,4 @@ import { Moment } from 'moment';
|
|
|
8
8
|
* @param orderFormat - The order format to check
|
|
9
9
|
* @returns The active opening interval or undefined if no interval is active for the given date and order format
|
|
10
10
|
*/
|
|
11
|
-
export default function getOutletActiveOpeningInterval(date: Moment, openingHours:
|
|
11
|
+
export default function getOutletActiveOpeningInterval(date: Moment, openingHours: OpeningHours[], orderFormat: OrderFormat): OpeningHours | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("@ancon/wildcat-types"),
|
|
1
|
+
"use strict";const n=require("@ancon/wildcat-types"),p=require("moment"),l=require("../shared/constants.js");function y(r,c,i){const a=c.reduce((t,e)=>{if((e.orderFormat&i)===i)switch(e.type){case n.IntervalType.Exception:{const s=p(e.periodFrom),f=p(e.periodTo);r.isBetween(s,f,"day","[]")&&(e.state===n.IntervalState.Closed?t.closedExceptions.push(e):t.openExceptions.push(e))}break;case n.IntervalType.Interval:default:(e.dayOfWeek===n.DayOfWeek.Everyday||e.dayOfWeek===l.DaysOfWeekMap[r.isoWeekday()])&&t.openIntervals.push(e);break}return t},{closedExceptions:[],openExceptions:[],openIntervals:[]}),{closedExceptions:d,openExceptions:o,openIntervals:u}=a;if(!d.length){if(o.length){if(o.length>1){const[t]=o.sort((e,s)=>e.position-s.position);return t}return o[0]}return u[0]}}module.exports=y;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
-
import { DayOfWeek as
|
|
1
|
+
import { DayOfWeek as l, IntervalType as r, IntervalState as m } from "@ancon/wildcat-types";
|
|
2
|
+
import i from "moment";
|
|
2
3
|
import { DaysOfWeekMap as y } from "../shared/constants.mjs";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function O(s, c, p) {
|
|
6
|
-
const f = c.reduce(
|
|
4
|
+
function k(s, f, p) {
|
|
5
|
+
const c = f.reduce(
|
|
7
6
|
(o, e) => {
|
|
8
7
|
if ((e.orderFormat & p) === p)
|
|
9
8
|
switch (e.type) {
|
|
10
9
|
case r.Exception:
|
|
11
10
|
{
|
|
12
|
-
const n = i(
|
|
13
|
-
|
|
14
|
-
), l = i(e.periodTo);
|
|
15
|
-
s.isBetween(n, l, "day", "[]") && (e.state === m.Closed ? o.closedExceptions.push(e) : o.openExceptions.push(e));
|
|
11
|
+
const n = i(e.periodFrom), u = i(e.periodTo);
|
|
12
|
+
s.isBetween(n, u, "day", "[]") && (e.state === m.Closed ? o.closedExceptions.push(e) : o.openExceptions.push(e));
|
|
16
13
|
}
|
|
17
14
|
break;
|
|
18
|
-
case r.
|
|
15
|
+
case r.Interval:
|
|
19
16
|
default:
|
|
20
17
|
// Every day in the week
|
|
21
|
-
(e.dayOfWeek ===
|
|
18
|
+
(e.dayOfWeek === l.Everyday || // Specific day in the week
|
|
22
19
|
e.dayOfWeek === y[s.isoWeekday()]) && o.openIntervals.push(e);
|
|
23
20
|
break;
|
|
24
21
|
}
|
|
@@ -29,8 +26,8 @@ function O(s, c, p) {
|
|
|
29
26
|
openExceptions: [],
|
|
30
27
|
openIntervals: []
|
|
31
28
|
}
|
|
32
|
-
), { closedExceptions:
|
|
33
|
-
if (!
|
|
29
|
+
), { closedExceptions: d, openExceptions: t, openIntervals: a } = c;
|
|
30
|
+
if (!d.length) {
|
|
34
31
|
if (t.length) {
|
|
35
32
|
if (t.length > 1) {
|
|
36
33
|
const [o] = t.sort(
|
|
@@ -40,9 +37,9 @@ function O(s, c, p) {
|
|
|
40
37
|
}
|
|
41
38
|
return t[0];
|
|
42
39
|
}
|
|
43
|
-
return
|
|
40
|
+
return a[0];
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
export {
|
|
47
|
-
|
|
44
|
+
k as default
|
|
48
45
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("moment"),l=require("@ancon/wildcat-types"),r=60;var c=(e=>(e[e.Today=0]="Today",e[e.Tomorrow=1]="Tomorrow",e))(c||{});function o(e,t,d=!1){let s=null;if(e.openNow&&e.closingTime!==null)(e.closingTime.diff(t,"minutes")<r||d)&&(s={time:e.closingTime.utcOffset(t.utcOffset()).format("LT"),state:l.OutletState.Closed});else if(!e.openNow&&e.openingTime)if(e.openingTime.isSame(t,"d"))s={time:f(e.openingTime).utcOffset(t.utcOffset()).calendar(),state:l.OutletState.Open};else{const u=f().add(1,"day").utcOffset(t.utcOffset()),i=f(e.openingTime).utcOffset(t.utcOffset());i.isSame(u,"d")?s={time:i.format("LT"),state:l.OutletState.Open,day:1}:i.isAfter(t.clone().add(1,"week"))?s={time:i.format("D MMMM LT"),state:l.OutletState.Open}:i&&(s={time:i.format("ddd LT"),state:l.OutletState.Open})}return s}exports.OutletAvailabilityDay=c;exports.default=o;
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { OutletState as
|
|
3
|
-
const
|
|
4
|
-
var
|
|
5
|
-
function
|
|
1
|
+
import d from "moment";
|
|
2
|
+
import { OutletState as i } from "@ancon/wildcat-types";
|
|
3
|
+
const l = 60;
|
|
4
|
+
var o = /* @__PURE__ */ ((e) => (e[e.Today = 0] = "Today", e[e.Tomorrow = 1] = "Tomorrow", e))(o || {});
|
|
5
|
+
function T(e, t, m = !1) {
|
|
6
6
|
let s = null;
|
|
7
7
|
if (e.openNow && e.closingTime !== null)
|
|
8
|
-
(e.closingTime.diff(
|
|
9
|
-
time: e.closingTime.format("LT"),
|
|
10
|
-
state:
|
|
8
|
+
(e.closingTime.diff(t, "minutes") < l || m) && (s = {
|
|
9
|
+
time: e.closingTime.utcOffset(t.utcOffset()).format("LT"),
|
|
10
|
+
state: i.Closed
|
|
11
11
|
});
|
|
12
12
|
else if (!e.openNow && e.openingTime)
|
|
13
|
-
if (e.openingTime.isSame(
|
|
13
|
+
if (e.openingTime.isSame(t, "d"))
|
|
14
14
|
s = {
|
|
15
|
-
time:
|
|
16
|
-
state:
|
|
15
|
+
time: d(e.openingTime).utcOffset(t.utcOffset()).calendar(),
|
|
16
|
+
state: i.Open
|
|
17
17
|
};
|
|
18
18
|
else {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
const c = d().add(1, "day").utcOffset(t.utcOffset()), f = d(e.openingTime).utcOffset(
|
|
20
|
+
t.utcOffset()
|
|
21
|
+
);
|
|
22
|
+
f.isSame(c, "d") ? s = {
|
|
23
|
+
time: f.format("LT"),
|
|
24
|
+
state: i.Open,
|
|
23
25
|
day: 1
|
|
24
26
|
/* Tomorrow */
|
|
25
|
-
} :
|
|
26
|
-
time:
|
|
27
|
-
state:
|
|
28
|
-
} :
|
|
29
|
-
time:
|
|
30
|
-
state:
|
|
27
|
+
} : f.isAfter(t.clone().add(1, "week")) ? s = {
|
|
28
|
+
time: f.format("D MMMM LT"),
|
|
29
|
+
state: i.Open
|
|
30
|
+
} : f && (s = {
|
|
31
|
+
time: f.format("ddd LT"),
|
|
32
|
+
state: i.Open
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
return s;
|
|
34
36
|
}
|
|
35
37
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
o as OutletAvailabilityDay,
|
|
39
|
+
T as default
|
|
38
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const a=require("@ancon/wildcat-types"),
|
|
1
|
+
"use strict";const a=require("@ancon/wildcat-types"),u=require("./getMomentFromDateAndTimeString.js");require("moment");function m(s,e,l){if(e.exception){const{exception:t}=e;if(t.type===a.IntervalType.Interval){const[n,o]=t.duration.split(":").map(Number),i=u(s,t.start),r=i.clone().add(n,"hours").add(o,"minutes");if(l.isBetween(i,r))return e.exception}}else for(let t=0;t<e.intervals.length;t+=1){const n=e.intervals[t],[o,i]=n.duration.split(":").map(Number),r=u(s,n.start),c=r.clone().add(o,"hours").add(i,"minutes");if(l.isBetween(r,c))return n}return null}module.exports=m;
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import { IntervalType as
|
|
2
|
-
import
|
|
3
|
-
import m from "./getMomentFromDateAndTimeString.mjs";
|
|
1
|
+
import { IntervalType as m } from "@ancon/wildcat-types";
|
|
2
|
+
import u from "./getMomentFromDateAndTimeString.mjs";
|
|
4
3
|
import "moment";
|
|
5
|
-
function
|
|
4
|
+
function d(s, n, l) {
|
|
6
5
|
if (n.exception) {
|
|
7
6
|
const { exception: t } = n;
|
|
8
|
-
if (t.type ===
|
|
9
|
-
const e =
|
|
10
|
-
|
|
11
|
-
t.
|
|
12
|
-
),
|
|
13
|
-
if (l.isBetween(
|
|
7
|
+
if (t.type === m.Interval) {
|
|
8
|
+
const [e, r] = t.duration.split(":").map(Number), i = u(
|
|
9
|
+
s,
|
|
10
|
+
t.start
|
|
11
|
+
), o = i.clone().add(e, "hours").add(r, "minutes");
|
|
12
|
+
if (l.isBetween(i, o))
|
|
14
13
|
return n.exception;
|
|
15
14
|
}
|
|
16
15
|
} else
|
|
17
16
|
for (let t = 0; t < n.intervals.length; t += 1) {
|
|
18
|
-
const e = n.intervals[t],
|
|
19
|
-
|
|
20
|
-
e.
|
|
21
|
-
),
|
|
22
|
-
if (l.isBetween(
|
|
17
|
+
const e = n.intervals[t], [r, i] = e.duration.split(":").map(Number), o = u(
|
|
18
|
+
s,
|
|
19
|
+
e.start
|
|
20
|
+
), c = o.clone().add(r, "hours").add(i, "minutes");
|
|
21
|
+
if (l.isBetween(o, c))
|
|
23
22
|
return e;
|
|
24
23
|
}
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
27
26
|
export {
|
|
28
|
-
|
|
27
|
+
d as default
|
|
29
28
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const T=require("@ancon/wildcat-types"),p=require("moment"),u=require("./getOutletTagInformation.js"),a=require("./getOutletAvailabilityInfo.js");require("./constants.js");require("./getOutletCurrentActiveOperatingHour.js");require("./getMomentFromDateAndTimeString.js");require("./searchNextOpeningMoment.js");function d(o,e){let{openingTime:i}=o,{closingTime:n}=o;return!!e.openingTime&&!!e.closingTime?(o.openingTime?o.openingTime.isBetween(e.openingTime,e.closingTime)&&(i=e.openingTime):i=e.openingTime,o.closingTime?o.closingTime.isBetween(e.openingTime,e.closingTime)&&(n=e.closingTime):n=e.closingTime):((!i&&e.openingTime||e.openingTime&&i&&e.openingTime.isBefore(i))&&(i=e.openingTime),!n&&e.closingTime?n=e.closingTime:e.closingTime&&n&&(e.closingTime.isBefore(n)||(n=e.closingTime))),{openingTime:i,closingTime:n}}function c(o){const{serviceDateTimes:e,state:i,timeZoneOffset:n}=o,l=p(),t=i===T.OutletState.Open,m=e.reduce((s,g)=>{const f=(g==null?void 0:g.intervals)||[],r=u.default(f,t,l,l,n);return s?s.openNow&&!r.openNow?s:{...d(s,r),openNow:s.openNow||r.openNow,openDuringSpecifiedTime:s.openDuringSpecifiedTime||r.openDuringSpecifiedTime}:r},void 0);return m?a.default(m,l,!1):null}module.exports=c;
|