@ancon/wildcat-utils 1.40.9 → 1.40.11
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/checkout/getCheckoutOrderStatusTexts.d.ts +4 -2
- package/checkout/getCheckoutOrderStatusTexts.js +2 -2
- package/checkout/getCheckoutOrderStatusTexts.mjs +86 -70
- package/checkout/isCheckoutAlreadyPaidStatus.js +1 -1
- package/checkout/isCheckoutAlreadyPaidStatus.mjs +1 -0
- package/outlet/getListOutletOpeningHoursTable.js +1 -1
- package/outlet/getListOutletOpeningHoursTable.mjs +37 -35
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AttendeePreOrderStatus, CheckoutStatus, OrderFormat, PreOrderStatus, TicketItemStatus, TicketStatus } from '@ancon/wildcat-types';
|
|
1
|
+
import { AttendeePreOrderStatus, CheckoutDeliveryStatus, CheckoutStatus, OrderFormat, PreOrderStatus, TicketItemStatus, TicketStatus } from '@ancon/wildcat-types';
|
|
2
2
|
declare type CheckoutOrderSummaryItem = {
|
|
3
3
|
ticketItem: {
|
|
4
4
|
status: TicketItemStatus;
|
|
@@ -16,6 +16,7 @@ declare type Options = {
|
|
|
16
16
|
checkoutStatus?: CheckoutStatus;
|
|
17
17
|
ticketStatus?: TicketStatus;
|
|
18
18
|
preOrderOptions?: PreOrderOptions;
|
|
19
|
+
deliveryStatus?: CheckoutDeliveryStatus;
|
|
19
20
|
};
|
|
20
21
|
export declare type PreOrderOptions = {
|
|
21
22
|
isHost: boolean;
|
|
@@ -50,7 +51,8 @@ declare enum TranslationKey {
|
|
|
50
51
|
OneItemIsReadyToCollect = "oneItemIsReadyToCollect",
|
|
51
52
|
MultipleItemsAreReadyToCollect = "multipleItemsAreReadyToCollect",
|
|
52
53
|
EnjoyMealWhileOtherItemsBeingPrepared = "enjoyMealWhileOtherItemsBeingPrepared",
|
|
53
|
-
ThereWasAnError = "thereWasAnError"
|
|
54
|
+
ThereWasAnError = "thereWasAnError",
|
|
55
|
+
YourOrderReadyToPickupFromLocker = "yourOrderReadyToPickupFromLocker"
|
|
54
56
|
}
|
|
55
57
|
declare type TranslationsWithMeta = {
|
|
56
58
|
[TranslationKey.MultipleItemsAreReadyToCollect]: ({ meta, }: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@ancon/wildcat-types"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@ancon/wildcat-types"),v=require("./getCheckoutItemsMappedByTicketItemStatus.js");var m=(e=>(e.OrderConfirmedHostWillApproveAndProcess="orderConfirmedHostWillApproveAndProcess",e.OrderConfirmedRestaurantAdminWillAcceptSoon="orderConfirmedRestaurantAdminWillAcceptSoon",e.YourOrderHasBeenApprovedByHost="yourOrderHasBeenApprovedByHost",e.YourOrderIsBeingProcessed="yourOrderIsBeingProcessed",e.YourOrderWasCancelled="yourOrderWasCancelled",e.ProcessingPayment="processingPayment",e.YourOrderIsBeingPrepared="yourOrderIsBeingPrepared",e.YourOrderIsReadyToCollect="yourOrderIsReadyToCollect",e.YourOrderIsBeingDelivered="yourOrderIsBeingDelivered",e.YourOrderHasBeenCompleted="yourOrderHasBeenCompleted",e.YourOrderWillArriveAtYourTable="yourOrderWillArriveAtYourTable",e.ModifiedDeliveryStartTime="modifiedDeliveryStartTime",e.ModifiedPickUpTime="modifiedPickUpTime",e.YourOrderHasBeenAcceptedEstimatedDeliveryStartTime="yourOrderHasBeenAcceptedEstimatedDeliveryStartTime",e.YourOrderIsBeingPreparedEstimatedDeliveryStartTime="yourOrderIsBeingPreparedEstimatedDeliveryStartTime",e.YourOrderHasBeenAcceptedEstimatedTime="yourOrderHasBeenAcceptedEstimatedTime",e.YourOrderHasBeenAcceptedPickupTime="yourOrderHasBeenAcceptedPickupTime",e.DeliveryWasCompleted="deliveryWasCompleted",e.OneItemIsReadyToCollect="oneItemIsReadyToCollect",e.MultipleItemsAreReadyToCollect="multipleItemsAreReadyToCollect",e.EnjoyMealWhileOtherItemsBeingPrepared="enjoyMealWhileOtherItemsBeingPrepared",e.ThereWasAnError="thereWasAnError",e.YourOrderReadyToPickupFromLocker="yourOrderReadyToPickupFromLocker",e))(m||{});function T(e,o){switch(e){case r.CheckoutStatus.Error:return"thereWasAnError";case r.CheckoutStatus.Created:case r.CheckoutStatus.Ready:case r.CheckoutStatus.Processing:case r.CheckoutStatus.Authorized:return"yourOrderIsBeingProcessed";case r.CheckoutStatus.Canceled:return"yourOrderWasCancelled";case r.CheckoutStatus.Received:return"processingPayment";case r.CheckoutStatus.ReadyToCollect:return o?"yourOrderIsBeingDelivered":"yourOrderIsReadyToCollect";default:return null}}function A(e){switch(e){case r.TicketStatus.Pending:case r.TicketStatus.PendingAccept:return"yourOrderIsBeingProcessed";case r.TicketStatus.Preparing:return"yourOrderIsBeingPrepared";case r.TicketStatus.Ready:return"yourOrderIsReadyToCollect";case r.TicketStatus.Closed:return"yourOrderHasBeenCompleted";case r.TicketStatus.Canceled:return"yourOrderWasCancelled";default:throw new Error(`Unhandled ticket status "${e}" in getTranslationKeyByTicketStatus()`)}}function B(e){const{isHost:o,preOrderStatus:i,preOrderAttendeeStatus:d}=e;if(d===r.AttendeePreOrderStatus.Confirmed)switch(i){case r.PreOrderStatus.Started:return"orderConfirmedHostWillApproveAndProcess";case r.PreOrderStatus.Waiting:return o?"orderConfirmedRestaurantAdminWillAcceptSoon":"yourOrderHasBeenApprovedByHost"}return null}function I(e,{checkoutStatus:o,ticketStatus:i,customersFetchTableOrders:d}){const a=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery,s=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,n=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder;if(a||s||n&&!d)return!1;const t=o!=null,l=i!=null;if(t){const u=o===r.CheckoutStatus.Captured,c=o===r.CheckoutStatus.InProgress;return u||c}if(l){const u=i===r.TicketStatus.Preparing,c=i===r.TicketStatus.Ready;return u||c}return!1}function k(e,{checkoutStatus:o,ticketStatus:i,customersFetchTableOrders:d,pickupTimeUpdated:a,preOrderOptions:s,deliveryStatus:n},t){if(t&&I(e,{checkoutStatus:o,ticketStatus:i,customersFetchTableOrders:d})){if(t.ready>0)return t.ready<2?["oneItemIsReadyToCollect"]:["multipleItemsAreReadyToCollect",{count:t.ready}];if(t.done>0&&t.done<t.all)return["enjoyMealWhileOtherItemsBeingPrepared",{count:Math.max(0,t.all-t.done-t.ready)}]}if(i!=null)return[A(i)];if(s&&(o===r.CheckoutStatus.Created||o===r.CheckoutStatus.Authorized)){const f=B(s);if(f)return[f]}const l=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery,u=T(o,l);if(u)return[u];const c=o===r.CheckoutStatus.Captured,g=o===r.CheckoutStatus.InProgress,C=o===r.CheckoutStatus.Done,h=o===r.CheckoutStatus.DeliveryInProgress,p=(e==null?void 0:e.orderFormat)===r.OrderFormat.EatIn,y=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,O=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder,P=(e==null?void 0:e.orderFormat)===r.OrderFormat.BoxPickup;if(c)return O&&!d?["yourOrderWillArriveAtYourTable"]:l?a?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"]:a?["modifiedPickUpTime"]:["yourOrderHasBeenAcceptedPickupTime"];if(g){if(l)return a?["modifiedDeliveryStartTime"]:["yourOrderIsBeingPreparedEstimatedDeliveryStartTime"];if(t&&(p||y)){if(t.ready===t.all)return["yourOrderIsReadyToCollect"];if(t.done===t.all)return["yourOrderHasBeenCompleted"]}if(O){if(t){if(t.ready===t.all)return d?["yourOrderIsReadyToCollect"]:["yourOrderWillArriveAtYourTable"];if(t.done===t.all)return d?["yourOrderHasBeenCompleted"]:["yourOrderWillArriveAtYourTable"]}return a?["modifiedPickUpTime"]:d?["yourOrderIsBeingPrepared"]:["yourOrderWillArriveAtYourTable"]}return a?["modifiedPickUpTime"]:["yourOrderIsBeingPrepared"]}if(C)return p||y?["yourOrderHasBeenCompleted"]:l?["deliveryWasCompleted"]:["yourOrderHasBeenCompleted"];if(h&&P){if(n===r.CheckoutDeliveryStatus.Pending)return["yourOrderReadyToPickupFromLocker"];if(n===r.CheckoutDeliveryStatus.Delivered)return["yourOrderHasBeenCompleted"]}throw new Error("Could not resolve translation key in getTranslationKey()")}const S={orderConfirmedHostWillApproveAndProcess:()=>({title:`Order Confirmed!
|
|
2
2
|
The host will approve and process the pre-order.`,message:"Please contact the host if you want to edit your order."}),orderConfirmedRestaurantAdminWillAcceptSoon:()=>({title:`Order Confirmed!
|
|
3
|
-
The restaurant admin will accept your pre-order soon.`}),yourOrderHasBeenApprovedByHost:()=>({title:"Your order has been approved by host!",message:"The restaurant admin will accept and process the pre-order"}),yourOrderIsBeingProcessed:()=>({title:"Your order is being processed"}),yourOrderWasCancelled:()=>({title:"Your order was canceled",message:"Sorry. Your order could not go through."}),processingPayment:()=>({title:"Processing payment",message:"Please wait while your payment is being processed"}),yourOrderIsBeingPrepared:()=>({title:"Your order is now being prepared!",message:"We will let you know when it is ready for pickup."}),yourOrderIsReadyToCollect:()=>({title:"Your order is ready to be collected!",message:"Please go ahead and show this screen at the collection point"}),yourOrderIsBeingDelivered:()=>({title:"Your order is being delivered",message:"It will arrive at your door shortly. Enjoy your meal!"}),yourOrderHasBeenCompleted:()=>({title:"Enjoy your meal!",message:"Your order has been completed!"}),yourOrderWillArriveAtYourTable:()=>({title:"Your order has been accepted!",message:"It will arrive at your table shortly"}),modifiedDeliveryStartTime:()=>({title:"Your delivery time was modified",message:"Delivery will start at approximately 00:00."}),modifiedPickUpTime:()=>({title:"Your pickup time was modified",message:"Pickup time: 00:00"}),yourOrderHasBeenAcceptedEstimatedDeliveryStartTime:()=>({title:"Your order has been accepted",message:"Estimated delivery start time: 00:00"}),yourOrderIsBeingPreparedEstimatedDeliveryStartTime:()=>({title:"Your order is now being prepared!",message:"Estimated delivery start time: 00:00"}),yourOrderHasBeenAcceptedEstimatedTime:()=>({title:"Your order has been accepted",message:"Estimated time: 00:00"}),yourOrderHasBeenAcceptedPickupTime:()=>({title:"Your order has been accepted",message:"Pickup time: 00:00"}),deliveryWasCompleted:()=>({title:"Your order was completed",message:"Enjoy your meal!"}),oneItemIsReadyToCollect:()=>({title:"One item is ready to pick up!",message:"Please allow cashier or waiter to confirm that the prepared item has been successfully issued."}),multipleItemsAreReadyToCollect:()=>({title:"Multiple items are ready to pick up!",message:"Please allow cashier or waiter to confirm that the prepared items have been successfully issued."}),enjoyMealWhileOtherItemsBeingPrepared:({meta:e})=>({title:"Enjoy your meal while the rest of the items are being prepared!",message:`${e.count} more items are being prepared`}),thereWasAnError:()=>({title:"Checkout error",message:"There was an error with the checkout"})};function
|
|
3
|
+
The restaurant admin will accept your pre-order soon.`}),yourOrderHasBeenApprovedByHost:()=>({title:"Your order has been approved by host!",message:"The restaurant admin will accept and process the pre-order"}),yourOrderIsBeingProcessed:()=>({title:"Your order is being processed"}),yourOrderWasCancelled:()=>({title:"Your order was canceled",message:"Sorry. Your order could not go through."}),processingPayment:()=>({title:"Processing payment",message:"Please wait while your payment is being processed"}),yourOrderIsBeingPrepared:()=>({title:"Your order is now being prepared!",message:"We will let you know when it is ready for pickup."}),yourOrderIsReadyToCollect:()=>({title:"Your order is ready to be collected!",message:"Please go ahead and show this screen at the collection point"}),yourOrderIsBeingDelivered:()=>({title:"Your order is being delivered",message:"It will arrive at your door shortly. Enjoy your meal!"}),yourOrderHasBeenCompleted:()=>({title:"Enjoy your meal!",message:"Your order has been completed!"}),yourOrderWillArriveAtYourTable:()=>({title:"Your order has been accepted!",message:"It will arrive at your table shortly"}),modifiedDeliveryStartTime:()=>({title:"Your delivery time was modified",message:"Delivery will start at approximately 00:00."}),modifiedPickUpTime:()=>({title:"Your pickup time was modified",message:"Pickup time: 00:00"}),yourOrderHasBeenAcceptedEstimatedDeliveryStartTime:()=>({title:"Your order has been accepted",message:"Estimated delivery start time: 00:00"}),yourOrderIsBeingPreparedEstimatedDeliveryStartTime:()=>({title:"Your order is now being prepared!",message:"Estimated delivery start time: 00:00"}),yourOrderHasBeenAcceptedEstimatedTime:()=>({title:"Your order has been accepted",message:"Estimated time: 00:00"}),yourOrderHasBeenAcceptedPickupTime:()=>({title:"Your order has been accepted",message:"Pickup time: 00:00"}),deliveryWasCompleted:()=>({title:"Your order was completed",message:"Enjoy your meal!"}),oneItemIsReadyToCollect:()=>({title:"One item is ready to pick up!",message:"Please allow cashier or waiter to confirm that the prepared item has been successfully issued."}),multipleItemsAreReadyToCollect:()=>({title:"Multiple items are ready to pick up!",message:"Please allow cashier or waiter to confirm that the prepared items have been successfully issued."}),enjoyMealWhileOtherItemsBeingPrepared:({meta:e})=>({title:"Enjoy your meal while the rest of the items are being prepared!",message:`${e.count} more items are being prepared`}),thereWasAnError:()=>({title:"Checkout error",message:"There was an error with the checkout"}),yourOrderReadyToPickupFromLocker:()=>({title:"Your order is ready to pick up from the locker!"})};function w(e,o){if(o)return;const i=v(e);return{all:i.all.length,ready:i.ready.length,done:i.done.length}}function Y(e,o,i=S){const{isSkipTicketStatus:d}=o,a=w((e==null?void 0:e.items)??[],d),[s,n]=k(e,o,a),t=i[s]({key:s,meta:n});if(!t)throw new Error("Could not resolve translation in getOrderStatusTexts()");return[t,s]}exports.TranslationKey=m;exports.default=Y;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { CheckoutStatus as
|
|
2
|
-
import
|
|
3
|
-
var
|
|
4
|
-
function
|
|
1
|
+
import { CheckoutStatus as o, OrderFormat as l, CheckoutDeliveryStatus as P, TicketStatus as s, AttendeePreOrderStatus as h, PreOrderStatus as C } from "@ancon/wildcat-types";
|
|
2
|
+
import T from "./getCheckoutItemsMappedByTicketItemStatus.mjs";
|
|
3
|
+
var w = /* @__PURE__ */ ((e) => (e.OrderConfirmedHostWillApproveAndProcess = "orderConfirmedHostWillApproveAndProcess", e.OrderConfirmedRestaurantAdminWillAcceptSoon = "orderConfirmedRestaurantAdminWillAcceptSoon", e.YourOrderHasBeenApprovedByHost = "yourOrderHasBeenApprovedByHost", e.YourOrderIsBeingProcessed = "yourOrderIsBeingProcessed", e.YourOrderWasCancelled = "yourOrderWasCancelled", e.ProcessingPayment = "processingPayment", e.YourOrderIsBeingPrepared = "yourOrderIsBeingPrepared", e.YourOrderIsReadyToCollect = "yourOrderIsReadyToCollect", e.YourOrderIsBeingDelivered = "yourOrderIsBeingDelivered", e.YourOrderHasBeenCompleted = "yourOrderHasBeenCompleted", e.YourOrderWillArriveAtYourTable = "yourOrderWillArriveAtYourTable", e.ModifiedDeliveryStartTime = "modifiedDeliveryStartTime", e.ModifiedPickUpTime = "modifiedPickUpTime", e.YourOrderHasBeenAcceptedEstimatedDeliveryStartTime = "yourOrderHasBeenAcceptedEstimatedDeliveryStartTime", e.YourOrderIsBeingPreparedEstimatedDeliveryStartTime = "yourOrderIsBeingPreparedEstimatedDeliveryStartTime", e.YourOrderHasBeenAcceptedEstimatedTime = "yourOrderHasBeenAcceptedEstimatedTime", e.YourOrderHasBeenAcceptedPickupTime = "yourOrderHasBeenAcceptedPickupTime", e.DeliveryWasCompleted = "deliveryWasCompleted", e.OneItemIsReadyToCollect = "oneItemIsReadyToCollect", e.MultipleItemsAreReadyToCollect = "multipleItemsAreReadyToCollect", e.EnjoyMealWhileOtherItemsBeingPrepared = "enjoyMealWhileOtherItemsBeingPrepared", e.ThereWasAnError = "thereWasAnError", e.YourOrderReadyToPickupFromLocker = "yourOrderReadyToPickupFromLocker", e))(w || {});
|
|
4
|
+
function Y(e, t) {
|
|
5
5
|
switch (e) {
|
|
6
|
-
case
|
|
6
|
+
case o.Error:
|
|
7
7
|
return "thereWasAnError";
|
|
8
|
-
case
|
|
9
|
-
case
|
|
10
|
-
case
|
|
11
|
-
case
|
|
8
|
+
case o.Created:
|
|
9
|
+
case o.Ready:
|
|
10
|
+
case o.Processing:
|
|
11
|
+
case o.Authorized:
|
|
12
12
|
return "yourOrderIsBeingProcessed";
|
|
13
|
-
case
|
|
13
|
+
case o.Canceled:
|
|
14
14
|
return "yourOrderWasCancelled";
|
|
15
|
-
case
|
|
15
|
+
case o.Received:
|
|
16
16
|
return "processingPayment";
|
|
17
|
-
case
|
|
17
|
+
case o.ReadyToCollect:
|
|
18
18
|
return t ? "yourOrderIsBeingDelivered" : "yourOrderIsReadyToCollect";
|
|
19
19
|
default:
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function W(e) {
|
|
24
24
|
switch (e) {
|
|
25
|
-
case
|
|
26
|
-
case
|
|
25
|
+
case s.Pending:
|
|
26
|
+
case s.PendingAccept:
|
|
27
27
|
return "yourOrderIsBeingProcessed";
|
|
28
|
-
case
|
|
28
|
+
case s.Preparing:
|
|
29
29
|
return "yourOrderIsBeingPrepared";
|
|
30
|
-
case
|
|
30
|
+
case s.Ready:
|
|
31
31
|
return "yourOrderIsReadyToCollect";
|
|
32
|
-
case
|
|
32
|
+
case s.Closed:
|
|
33
33
|
return "yourOrderHasBeenCompleted";
|
|
34
|
-
case
|
|
34
|
+
case s.Canceled:
|
|
35
35
|
return "yourOrderWasCancelled";
|
|
36
36
|
default:
|
|
37
37
|
throw new Error(
|
|
@@ -39,10 +39,10 @@ function I(e) {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
const { isHost: t, preOrderStatus:
|
|
44
|
-
if (d ===
|
|
45
|
-
switch (
|
|
42
|
+
function H(e) {
|
|
43
|
+
const { isHost: t, preOrderStatus: i, preOrderAttendeeStatus: d } = e;
|
|
44
|
+
if (d === h.Confirmed)
|
|
45
|
+
switch (i) {
|
|
46
46
|
case C.Started:
|
|
47
47
|
return "orderConfirmedHostWillApproveAndProcess";
|
|
48
48
|
case C.Waiting:
|
|
@@ -50,35 +50,36 @@ function T(e) {
|
|
|
50
50
|
}
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function k(e, {
|
|
54
54
|
checkoutStatus: t,
|
|
55
|
-
ticketStatus:
|
|
55
|
+
ticketStatus: i,
|
|
56
56
|
customersFetchTableOrders: d
|
|
57
57
|
}) {
|
|
58
|
-
const a = (e == null ? void 0 : e.orderFormat) ===
|
|
59
|
-
if (a || n ||
|
|
58
|
+
const a = (e == null ? void 0 : e.orderFormat) === l.Delivery, n = (e == null ? void 0 : e.orderFormat) === l.TakeAway, u = (e == null ? void 0 : e.orderFormat) === l.TableOrder;
|
|
59
|
+
if (a || n || u && !d)
|
|
60
60
|
return !1;
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
return
|
|
61
|
+
const r = t != null, c = i != null;
|
|
62
|
+
if (r) {
|
|
63
|
+
const p = t === o.Captured, y = t === o.InProgress;
|
|
64
|
+
return p || y;
|
|
65
65
|
}
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
return
|
|
66
|
+
if (c) {
|
|
67
|
+
const p = i === s.Preparing, y = i === s.Ready;
|
|
68
|
+
return p || y;
|
|
69
69
|
}
|
|
70
70
|
return !1;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function D(e, {
|
|
73
73
|
checkoutStatus: t,
|
|
74
|
-
ticketStatus:
|
|
74
|
+
ticketStatus: i,
|
|
75
75
|
customersFetchTableOrders: d,
|
|
76
76
|
pickupTimeUpdated: a,
|
|
77
|
-
preOrderOptions: n
|
|
77
|
+
preOrderOptions: n,
|
|
78
|
+
deliveryStatus: u
|
|
78
79
|
}, r) {
|
|
79
|
-
if (r &&
|
|
80
|
+
if (r && k(e, {
|
|
80
81
|
checkoutStatus: t,
|
|
81
|
-
ticketStatus:
|
|
82
|
+
ticketStatus: i,
|
|
82
83
|
customersFetchTableOrders: d
|
|
83
84
|
})) {
|
|
84
85
|
if (r.ready > 0)
|
|
@@ -95,25 +96,25 @@ function Y(e, {
|
|
|
95
96
|
{ count: Math.max(0, r.all - r.done - r.ready) }
|
|
96
97
|
];
|
|
97
98
|
}
|
|
98
|
-
if (
|
|
99
|
-
return [
|
|
100
|
-
if (n && (t ===
|
|
101
|
-
const O =
|
|
99
|
+
if (i != null)
|
|
100
|
+
return [W(i)];
|
|
101
|
+
if (n && (t === o.Created || t === o.Authorized)) {
|
|
102
|
+
const O = H(n);
|
|
102
103
|
if (O)
|
|
103
104
|
return [O];
|
|
104
105
|
}
|
|
105
|
-
const
|
|
106
|
+
const c = (e == null ? void 0 : e.orderFormat) === l.Delivery, p = Y(
|
|
106
107
|
t,
|
|
107
|
-
|
|
108
|
+
c
|
|
108
109
|
);
|
|
110
|
+
if (p)
|
|
111
|
+
return [p];
|
|
112
|
+
const y = t === o.Captured, A = t === o.InProgress, B = t === o.Done, v = t === o.DeliveryInProgress, f = (e == null ? void 0 : e.orderFormat) === l.EatIn, g = (e == null ? void 0 : e.orderFormat) === l.TakeAway, m = (e == null ? void 0 : e.orderFormat) === l.TableOrder, I = (e == null ? void 0 : e.orderFormat) === l.BoxPickup;
|
|
109
113
|
if (y)
|
|
110
|
-
return [
|
|
111
|
-
const c = t === i.Captured, p = t === i.InProgress, P = t === i.Done, m = (e == null ? void 0 : e.orderFormat) === u.EatIn, f = (e == null ? void 0 : e.orderFormat) === u.TakeAway, g = (e == null ? void 0 : e.orderFormat) === u.TableOrder;
|
|
112
|
-
if (c)
|
|
113
|
-
return g && !d ? [
|
|
114
|
+
return m && !d ? [
|
|
114
115
|
"yourOrderWillArriveAtYourTable"
|
|
115
116
|
/* YourOrderWillArriveAtYourTable */
|
|
116
|
-
] :
|
|
117
|
+
] : c ? a ? [
|
|
117
118
|
"modifiedDeliveryStartTime"
|
|
118
119
|
/* ModifiedDeliveryStartTime */
|
|
119
120
|
] : [
|
|
@@ -126,8 +127,8 @@ function Y(e, {
|
|
|
126
127
|
"yourOrderHasBeenAcceptedPickupTime"
|
|
127
128
|
/* YourOrderHasBeenAcceptedPickupTime */
|
|
128
129
|
];
|
|
129
|
-
if (
|
|
130
|
-
if (
|
|
130
|
+
if (A) {
|
|
131
|
+
if (c)
|
|
131
132
|
return a ? [
|
|
132
133
|
"modifiedDeliveryStartTime"
|
|
133
134
|
/* ModifiedDeliveryStartTime */
|
|
@@ -135,7 +136,7 @@ function Y(e, {
|
|
|
135
136
|
"yourOrderIsBeingPreparedEstimatedDeliveryStartTime"
|
|
136
137
|
/* YourOrderIsBeingPreparedEstimatedDeliveryStartTime */
|
|
137
138
|
];
|
|
138
|
-
if (r && (
|
|
139
|
+
if (r && (f || g)) {
|
|
139
140
|
if (r.ready === r.all)
|
|
140
141
|
return [
|
|
141
142
|
"yourOrderIsReadyToCollect"
|
|
@@ -147,7 +148,7 @@ function Y(e, {
|
|
|
147
148
|
/* YourOrderHasBeenCompleted */
|
|
148
149
|
];
|
|
149
150
|
}
|
|
150
|
-
if (
|
|
151
|
+
if (m) {
|
|
151
152
|
if (r) {
|
|
152
153
|
if (r.ready === r.all)
|
|
153
154
|
return d ? [
|
|
@@ -185,20 +186,32 @@ function Y(e, {
|
|
|
185
186
|
/* YourOrderIsBeingPrepared */
|
|
186
187
|
];
|
|
187
188
|
}
|
|
188
|
-
if (
|
|
189
|
-
return
|
|
189
|
+
if (B)
|
|
190
|
+
return f || g ? [
|
|
190
191
|
"yourOrderHasBeenCompleted"
|
|
191
192
|
/* YourOrderHasBeenCompleted */
|
|
192
|
-
] :
|
|
193
|
+
] : c ? [
|
|
193
194
|
"deliveryWasCompleted"
|
|
194
195
|
/* DeliveryWasCompleted */
|
|
195
196
|
] : [
|
|
196
197
|
"yourOrderHasBeenCompleted"
|
|
197
198
|
/* YourOrderHasBeenCompleted */
|
|
198
199
|
];
|
|
200
|
+
if (v && I) {
|
|
201
|
+
if (u === P.Pending)
|
|
202
|
+
return [
|
|
203
|
+
"yourOrderReadyToPickupFromLocker"
|
|
204
|
+
/* YourOrderReadyToPickupFromLocker */
|
|
205
|
+
];
|
|
206
|
+
if (u === P.Delivered)
|
|
207
|
+
return [
|
|
208
|
+
"yourOrderHasBeenCompleted"
|
|
209
|
+
/* YourOrderHasBeenCompleted */
|
|
210
|
+
];
|
|
211
|
+
}
|
|
199
212
|
throw new Error("Could not resolve translation key in getTranslationKey()");
|
|
200
213
|
}
|
|
201
|
-
const
|
|
214
|
+
const R = {
|
|
202
215
|
orderConfirmedHostWillApproveAndProcess: () => ({
|
|
203
216
|
title: `Order Confirmed!
|
|
204
217
|
The host will approve and process the pre-order.`,
|
|
@@ -286,28 +299,31 @@ The restaurant admin will accept your pre-order soon.`
|
|
|
286
299
|
thereWasAnError: () => ({
|
|
287
300
|
title: "Checkout error",
|
|
288
301
|
message: "There was an error with the checkout"
|
|
302
|
+
}),
|
|
303
|
+
yourOrderReadyToPickupFromLocker: () => ({
|
|
304
|
+
title: "Your order is ready to pick up from the locker!"
|
|
289
305
|
})
|
|
290
306
|
};
|
|
291
|
-
function
|
|
307
|
+
function E(e, t) {
|
|
292
308
|
if (t)
|
|
293
309
|
return;
|
|
294
|
-
const
|
|
310
|
+
const i = T(e);
|
|
295
311
|
return {
|
|
296
|
-
all:
|
|
297
|
-
ready:
|
|
298
|
-
done:
|
|
312
|
+
all: i.all.length,
|
|
313
|
+
ready: i.ready.length,
|
|
314
|
+
done: i.done.length
|
|
299
315
|
};
|
|
300
316
|
}
|
|
301
|
-
function
|
|
302
|
-
const { isSkipTicketStatus: d } = t, a =
|
|
317
|
+
function M(e, t, i = R) {
|
|
318
|
+
const { isSkipTicketStatus: d } = t, a = E(
|
|
303
319
|
(e == null ? void 0 : e.items) ?? [],
|
|
304
320
|
d
|
|
305
|
-
), [n,
|
|
306
|
-
if (!
|
|
321
|
+
), [n, u] = D(e, t, a), r = i[n]({ key: n, meta: u });
|
|
322
|
+
if (!r)
|
|
307
323
|
throw new Error("Could not resolve translation in getOrderStatusTexts()");
|
|
308
|
-
return [
|
|
324
|
+
return [r, n];
|
|
309
325
|
}
|
|
310
326
|
export {
|
|
311
|
-
|
|
312
|
-
|
|
327
|
+
w as TranslationKey,
|
|
328
|
+
M as default
|
|
313
329
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const t=require("@ancon/wildcat-types");function s(e){throw new Error(`Unhandled checkout status: ${e}`)}function a(e){switch(e==null?void 0:e.status){case t.CheckoutStatus.Error:case t.CheckoutStatus.Canceled:case t.CheckoutStatus.Authorized:case t.CheckoutStatus.Captured:case t.CheckoutStatus.InProgress:case t.CheckoutStatus.Done:case t.CheckoutStatus.ReadyToCollect:return!0;case t.CheckoutStatus.Created:case t.CheckoutStatus.Ready:case t.CheckoutStatus.Processing:case t.CheckoutStatus.Received:return!1;default:return s(e==null?void 0:e.status)}}module.exports=a;
|
|
1
|
+
"use strict";const t=require("@ancon/wildcat-types");function s(e){throw new Error(`Unhandled checkout status: ${e}`)}function a(e){switch(e==null?void 0:e.status){case t.CheckoutStatus.Error:case t.CheckoutStatus.Canceled:case t.CheckoutStatus.Authorized:case t.CheckoutStatus.Captured:case t.CheckoutStatus.InProgress:case t.CheckoutStatus.Done:case t.CheckoutStatus.ReadyToCollect:case t.CheckoutStatus.DeliveryInProgress:return!0;case t.CheckoutStatus.Created:case t.CheckoutStatus.Ready:case t.CheckoutStatus.Processing:case t.CheckoutStatus.Received:return!1;default:return s(e==null?void 0:e.status)}}module.exports=a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const F=require("moment"),r=require("@ancon/wildcat-types"),g=require("../shared/isWithinFlag.js"),
|
|
1
|
+
"use strict";const F=require("moment"),r=require("@ancon/wildcat-types"),g=require("../shared/isWithinFlag.js"),k=require("../shared/generateId.js"),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,12 +1,13 @@
|
|
|
1
1
|
import S from "moment";
|
|
2
|
-
import { OrderFormat as
|
|
2
|
+
import { OrderFormat as y, DayOfWeek as l, IntervalType as c, IntervalState as g } from "@ancon/wildcat-types";
|
|
3
3
|
import h from "../shared/isWithinFlag.mjs";
|
|
4
4
|
import F from "../shared/generateId.mjs";
|
|
5
|
-
const
|
|
6
|
-
{ id:
|
|
7
|
-
{ id:
|
|
8
|
-
{ id:
|
|
9
|
-
{ id:
|
|
5
|
+
const k = [
|
|
6
|
+
{ id: y.EatIn, name: "eatIn" },
|
|
7
|
+
{ id: y.TakeAway, name: "takeaway" },
|
|
8
|
+
{ id: y.TableOrder, name: "tableOrder" },
|
|
9
|
+
{ id: y.Delivery, name: "delivery" },
|
|
10
|
+
{ id: y.BoxPickup, name: "boxPickup" }
|
|
10
11
|
];
|
|
11
12
|
function v(e) {
|
|
12
13
|
const o = S.utc(e).subtract(1, "day").startOf("day"), t = [];
|
|
@@ -20,7 +21,7 @@ function T(e) {
|
|
|
20
21
|
function W(e) {
|
|
21
22
|
return e.split(":").map(Number);
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
+
function x(e, o, t) {
|
|
24
25
|
const [n, s] = W(e.start), [m, u] = W(
|
|
25
26
|
e.duration
|
|
26
27
|
), [r, p] = W(t || "00:00:00");
|
|
@@ -50,19 +51,19 @@ function M(e, o, t) {
|
|
|
50
51
|
}
|
|
51
52
|
throw new Error("Invalid interval type");
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
+
function M(e, o, t, n) {
|
|
54
55
|
const s = {
|
|
55
|
-
[
|
|
56
|
-
[
|
|
57
|
-
[
|
|
58
|
-
[
|
|
59
|
-
[
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
56
|
+
[l.Monday]: 1,
|
|
57
|
+
[l.Tuesday]: 2,
|
|
58
|
+
[l.Wednesday]: 3,
|
|
59
|
+
[l.Thursday]: 4,
|
|
60
|
+
[l.Friday]: 5,
|
|
61
|
+
[l.Saturday]: 6,
|
|
62
|
+
[l.Sunday]: 7,
|
|
63
|
+
[l.Everyday]: null
|
|
63
64
|
};
|
|
64
65
|
for (let m = 0; m < o.length; m += 1) {
|
|
65
|
-
const u = o[m], r = u.isoWeekday(), p = e.dayOfWeek, i = (s[p] ?? null) === r || p ===
|
|
66
|
+
const u = o[m], r = u.isoWeekday(), p = e.dayOfWeek, i = (s[p] ?? null) === r || p === l.Everyday;
|
|
66
67
|
if (t[r] || (t[r] = {
|
|
67
68
|
isoWeekday: r,
|
|
68
69
|
key: "",
|
|
@@ -70,7 +71,7 @@ function H(e, o, t, n) {
|
|
|
70
71
|
adjusted: [],
|
|
71
72
|
closed: []
|
|
72
73
|
}), i) {
|
|
73
|
-
const d =
|
|
74
|
+
const d = x(
|
|
74
75
|
e,
|
|
75
76
|
u,
|
|
76
77
|
n
|
|
@@ -79,7 +80,7 @@ function H(e, o, t, n) {
|
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function H(e) {
|
|
83
84
|
switch (e.type) {
|
|
84
85
|
case c.Exception:
|
|
85
86
|
return F("interval-exception");
|
|
@@ -91,7 +92,7 @@ function x(e) {
|
|
|
91
92
|
}
|
|
92
93
|
function E(e) {
|
|
93
94
|
const o = e.reduce(
|
|
94
|
-
(t, n) => (
|
|
95
|
+
(t, n) => (k.forEach((s) => {
|
|
95
96
|
h(s.id, n.orderFormats) && (t[s.id] || (t[s.id] = {
|
|
96
97
|
orderFormat: s,
|
|
97
98
|
intervals: []
|
|
@@ -105,11 +106,11 @@ function E(e) {
|
|
|
105
106
|
);
|
|
106
107
|
return Object.values(o);
|
|
107
108
|
}
|
|
108
|
-
function
|
|
109
|
+
function b(e, o) {
|
|
109
110
|
const t = o.reduce((n, s) => s <= e ? n + 1 : n, 0);
|
|
110
111
|
return e - t;
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function D(e) {
|
|
113
114
|
const { mergedTables: o } = e.reduce(
|
|
114
115
|
(t, n, s) => {
|
|
115
116
|
const m = t.mergedTables.findIndex(
|
|
@@ -137,7 +138,7 @@ function b(e) {
|
|
|
137
138
|
(i) => !t.skipOrderFormats.some((d) => d.id === i.id)
|
|
138
139
|
);
|
|
139
140
|
p.length > 0 && t.skipOrderFormats.push(...p);
|
|
140
|
-
const a =
|
|
141
|
+
const a = b(s, [...t.removedIndexes]);
|
|
141
142
|
return t.mergedTables.splice(a, 1), t.removedIndexes.push(s), t;
|
|
142
143
|
}
|
|
143
144
|
return t;
|
|
@@ -151,15 +152,15 @@ function j(e) {
|
|
|
151
152
|
...o,
|
|
152
153
|
intervals: o.intervals.map((t) => ({
|
|
153
154
|
...t,
|
|
154
|
-
id:
|
|
155
|
+
id: H(t)
|
|
155
156
|
}))
|
|
156
157
|
}));
|
|
157
158
|
}
|
|
158
|
-
function
|
|
159
|
+
function N(e, o) {
|
|
159
160
|
const t = E(
|
|
160
161
|
j(e.serviceDateTimes)
|
|
161
162
|
), n = v(o), s = T(n), m = t.reduce(
|
|
162
|
-
(a, i) => (a[i.orderFormat.id] || (a[i.orderFormat.id] = {}), i.intervals.reduce((d, f) => (
|
|
163
|
+
(a, i) => (a[i.orderFormat.id] || (a[i.orderFormat.id] = {}), i.intervals.reduce((d, f) => (M(
|
|
163
164
|
f,
|
|
164
165
|
s,
|
|
165
166
|
d,
|
|
@@ -167,10 +168,11 @@ function R(e, o) {
|
|
|
167
168
|
), d), a[i.orderFormat.id]), a),
|
|
168
169
|
{}
|
|
169
170
|
), u = {
|
|
170
|
-
[
|
|
171
|
-
[
|
|
172
|
-
[
|
|
173
|
-
[
|
|
171
|
+
[y.EatIn]: k[0],
|
|
172
|
+
[y.TakeAway]: k[1],
|
|
173
|
+
[y.TableOrder]: k[2],
|
|
174
|
+
[y.Delivery]: k[3],
|
|
175
|
+
[y.BoxPickup]: k[4]
|
|
174
176
|
}, r = Object.entries(
|
|
175
177
|
m
|
|
176
178
|
).map(([a, i]) => ({
|
|
@@ -180,21 +182,21 @@ function R(e, o) {
|
|
|
180
182
|
isoWeekday: Number(d),
|
|
181
183
|
key: f.key,
|
|
182
184
|
open: f.open.sort(
|
|
183
|
-
(O,
|
|
185
|
+
(O, I) => O.start.localeCompare(I.start)
|
|
184
186
|
),
|
|
185
187
|
adjusted: f.adjusted.sort(
|
|
186
|
-
(O,
|
|
188
|
+
(O, I) => O.start.localeCompare(I.start)
|
|
187
189
|
),
|
|
188
190
|
closed: f.closed.sort(
|
|
189
|
-
(O,
|
|
191
|
+
(O, I) => O.start.localeCompare(I.start)
|
|
190
192
|
)
|
|
191
193
|
})
|
|
192
194
|
)
|
|
193
195
|
}));
|
|
194
|
-
return
|
|
196
|
+
return D(r).sort(
|
|
195
197
|
(a, i) => a.orderFormats[0].id - i.orderFormats[0].id
|
|
196
198
|
);
|
|
197
199
|
}
|
|
198
200
|
export {
|
|
199
|
-
|
|
201
|
+
N as default
|
|
200
202
|
};
|