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