@ancon/wildcat-utils 1.20.13 → 1.20.15
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.
|
@@ -9,7 +9,8 @@ declare type CheckoutSummary = {
|
|
|
9
9
|
items: CheckoutOrderSummaryItem[];
|
|
10
10
|
};
|
|
11
11
|
declare type Options = {
|
|
12
|
-
|
|
12
|
+
/** Only relevant for table order */
|
|
13
|
+
customersFetchTableOrders: boolean;
|
|
13
14
|
pickupTimeUpdated: boolean;
|
|
14
15
|
} & ({
|
|
15
16
|
checkoutStatus: CheckoutStatus;
|
|
@@ -32,9 +33,9 @@ declare enum TranslationKey {
|
|
|
32
33
|
YourOrderWillArriveAtYourTable = "yourOrderWillArriveAtYourTable",
|
|
33
34
|
ModifiedDeliveryStartTime = "modifiedDeliveryStartTime",
|
|
34
35
|
ModifiedPickUpTime = "modifiedPickUpTime",
|
|
36
|
+
YourOrderHasBeenAcceptedEstimatedDeliveryStartTime = "yourOrderHasBeenAcceptedEstimatedDeliveryStartTime",
|
|
35
37
|
YourOrderHasBeenAcceptedEstimatedTime = "yourOrderHasBeenAcceptedEstimatedTime",
|
|
36
38
|
YourOrderHasBeenAcceptedPickupTime = "yourOrderHasBeenAcceptedPickupTime",
|
|
37
|
-
YourOrderIsBeingDelivered = "yourOrderIsBeingDelivered",
|
|
38
39
|
DeliveryWasCompleted = "deliveryWasCompleted",
|
|
39
40
|
OneItemIsReadyToCollect = "oneItemIsReadyToCollect",
|
|
40
41
|
MultipleItemsAreReadyToCollect = "multipleItemsAreReadyToCollect",
|
|
@@ -1 +1 @@
|
|
|
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"),f=require("./getCheckoutItemsMappedByTicketItemStatus.js");var g=(e=>(e.YourOrderIsBeingProcessed="yourOrderIsBeingProcessed",e.YourOrderWasCancelled="yourOrderWasCancelled",e.ProcessingPayment="processingPayment",e.YourOrderIsBeingPrepared="yourOrderIsBeingPrepared",e.YourOrderIsReadyToCollect="yourOrderIsReadyToCollect",e.YourOrderHasBeenCompleted="yourOrderHasBeenCompleted",e.YourOrderWillArriveAtYourTable="yourOrderWillArriveAtYourTable",e.ModifiedDeliveryStartTime="modifiedDeliveryStartTime",e.ModifiedPickUpTime="modifiedPickUpTime",e.YourOrderHasBeenAcceptedEstimatedDeliveryStartTime="yourOrderHasBeenAcceptedEstimatedDeliveryStartTime",e.YourOrderHasBeenAcceptedEstimatedTime="yourOrderHasBeenAcceptedEstimatedTime",e.YourOrderHasBeenAcceptedPickupTime="yourOrderHasBeenAcceptedPickupTime",e.DeliveryWasCompleted="deliveryWasCompleted",e.OneItemIsReadyToCollect="oneItemIsReadyToCollect",e.MultipleItemsAreReadyToCollect="multipleItemsAreReadyToCollect",e.EnjoyMealWhileOtherItemsBeingPrepared="enjoyMealWhileOtherItemsBeingPrepared",e))(g||{});function C(e){switch(e){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"yourOrderIsReadyToCollect";default:return null}}function m(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 T(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o}){const d=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery,t=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,l=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder;if(d||t||l&&!o)return!1;const u=i!=null,c=a!=null;if(u){const n=i===r.CheckoutStatus.Captured,s=i===r.CheckoutStatus.InProgress;return n||s}if(c){const n=a===r.TicketStatus.Preparing,s=a===r.TicketStatus.Ready;return n||s}return!1}function P(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o,pickupTimeUpdated:d},t){if(T(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o})){if(t.ready>0)return t.ready===t.all?["yourOrderIsReadyToCollect"]: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(a!=null)return[m(a)];const l=C(i);if(l)return[l];const u=i===r.CheckoutStatus.Captured,c=i===r.CheckoutStatus.InProgress,n=i===r.CheckoutStatus.Done,s=(e==null?void 0:e.orderFormat)===r.OrderFormat.EatIn,p=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,O=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder,y=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery;if(u)return O&&!o?["yourOrderWillArriveAtYourTable"]:y?d?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"]:d?["modifiedPickUpTime"]:["yourOrderHasBeenAcceptedPickupTime"];if(c){if(y)return d?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"];if(s||p){if(t.ready===t.all)return["yourOrderIsReadyToCollect"];if(t.done===t.all)return["yourOrderHasBeenCompleted"]}return O?t.ready===t.all?o?["yourOrderIsReadyToCollect"]:["yourOrderWillArriveAtYourTable"]:t.done===t.all?o?["yourOrderHasBeenCompleted"]:["yourOrderWillArriveAtYourTable"]:d?["modifiedPickUpTime"]:o?["yourOrderIsBeingPrepared"]:["yourOrderWillArriveAtYourTable"]:d?["modifiedPickUpTime"]:["yourOrderIsBeingPrepared"]}if(n)return s||p?["yourOrderHasBeenCompleted"]:y?["deliveryWasCompleted"]:["yourOrderHasBeenCompleted"];throw new Error("Could not resolve translation key in getTranslationKey()")}const h={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"}),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"}),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`})};function I(e,i,a=h){const o=f((e==null?void 0:e.items)??[]),[d,t]=P(e,i,{all:o.all.length,ready:o.ready.length,done:o.done.length}),l=a[d]({key:d,meta:t});if(!l)throw new Error("Could not resolve translation in getOrderStatusTexts()");return[l,d]}exports.TranslationKey=g;exports.default=I;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CheckoutStatus as t, OrderFormat as
|
|
1
|
+
import { CheckoutStatus as t, OrderFormat as s, TicketStatus as a } from "@ancon/wildcat-types";
|
|
2
2
|
import m from "./getCheckoutItemsMappedByTicketItemStatus.mjs";
|
|
3
|
-
var
|
|
4
|
-
function
|
|
3
|
+
var C = /* @__PURE__ */ ((e) => (e.YourOrderIsBeingProcessed = "yourOrderIsBeingProcessed", e.YourOrderWasCancelled = "yourOrderWasCancelled", e.ProcessingPayment = "processingPayment", e.YourOrderIsBeingPrepared = "yourOrderIsBeingPrepared", e.YourOrderIsReadyToCollect = "yourOrderIsReadyToCollect", e.YourOrderHasBeenCompleted = "yourOrderHasBeenCompleted", e.YourOrderWillArriveAtYourTable = "yourOrderWillArriveAtYourTable", e.ModifiedDeliveryStartTime = "modifiedDeliveryStartTime", e.ModifiedPickUpTime = "modifiedPickUpTime", e.YourOrderHasBeenAcceptedEstimatedDeliveryStartTime = "yourOrderHasBeenAcceptedEstimatedDeliveryStartTime", e.YourOrderHasBeenAcceptedEstimatedTime = "yourOrderHasBeenAcceptedEstimatedTime", e.YourOrderHasBeenAcceptedPickupTime = "yourOrderHasBeenAcceptedPickupTime", e.DeliveryWasCompleted = "deliveryWasCompleted", e.OneItemIsReadyToCollect = "oneItemIsReadyToCollect", e.MultipleItemsAreReadyToCollect = "multipleItemsAreReadyToCollect", e.EnjoyMealWhileOtherItemsBeingPrepared = "enjoyMealWhileOtherItemsBeingPrepared", e))(C || {});
|
|
4
|
+
function P(e) {
|
|
5
5
|
switch (e) {
|
|
6
6
|
case t.Created:
|
|
7
7
|
case t.Ready:
|
|
@@ -18,7 +18,7 @@ function I(e) {
|
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function I(e) {
|
|
22
22
|
switch (e) {
|
|
23
23
|
case a.Pending:
|
|
24
24
|
case a.PendingAccept:
|
|
@@ -37,36 +37,38 @@ function P(e) {
|
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
checkoutStatus:
|
|
42
|
-
ticketStatus:
|
|
40
|
+
function T(e, {
|
|
41
|
+
checkoutStatus: i,
|
|
42
|
+
ticketStatus: l,
|
|
43
|
+
customersFetchTableOrders: o
|
|
43
44
|
}) {
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
45
|
+
const d = (e == null ? void 0 : e.orderFormat) === s.Delivery, r = (e == null ? void 0 : e.orderFormat) === s.TakeAway, n = (e == null ? void 0 : e.orderFormat) === s.TableOrder;
|
|
46
|
+
if (d || r || n && !o)
|
|
46
47
|
return !1;
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
50
|
-
return
|
|
48
|
+
const y = i != null, p = l != null;
|
|
49
|
+
if (y) {
|
|
50
|
+
const u = i === t.Captured, c = i === t.InProgress;
|
|
51
|
+
return u || c;
|
|
51
52
|
}
|
|
52
|
-
if (
|
|
53
|
-
const
|
|
54
|
-
return
|
|
53
|
+
if (p) {
|
|
54
|
+
const u = l === a.Preparing, c = l === a.Ready;
|
|
55
|
+
return u || c;
|
|
55
56
|
}
|
|
56
57
|
return !1;
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
-
checkoutStatus:
|
|
60
|
-
ticketStatus:
|
|
61
|
-
|
|
62
|
-
pickupTimeUpdated:
|
|
59
|
+
function B(e, {
|
|
60
|
+
checkoutStatus: i,
|
|
61
|
+
ticketStatus: l,
|
|
62
|
+
customersFetchTableOrders: o,
|
|
63
|
+
pickupTimeUpdated: d
|
|
63
64
|
}, r) {
|
|
64
|
-
if (
|
|
65
|
-
checkoutStatus:
|
|
66
|
-
ticketStatus:
|
|
65
|
+
if (T(e, {
|
|
66
|
+
checkoutStatus: i,
|
|
67
|
+
ticketStatus: l,
|
|
68
|
+
customersFetchTableOrders: o
|
|
67
69
|
})) {
|
|
68
70
|
if (r.ready > 0)
|
|
69
|
-
return r.ready < 2 ? ["oneItemIsReadyToCollect"] : [
|
|
71
|
+
return r.ready === r.all ? ["yourOrderIsReadyToCollect"] : r.ready < 2 ? ["oneItemIsReadyToCollect"] : [
|
|
70
72
|
"multipleItemsAreReadyToCollect",
|
|
71
73
|
{ count: r.ready }
|
|
72
74
|
];
|
|
@@ -76,26 +78,27 @@ function T(e, {
|
|
|
76
78
|
{ count: Math.max(0, r.all - r.done - r.ready) }
|
|
77
79
|
];
|
|
78
80
|
}
|
|
79
|
-
if (
|
|
80
|
-
return [
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
return [
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
return
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return l ? ["yourOrderIsReadyToCollect"] : ["yourOrderWillArriveAtYourTable"];
|
|
81
|
+
if (l != null)
|
|
82
|
+
return [I(l)];
|
|
83
|
+
const n = P(i);
|
|
84
|
+
if (n)
|
|
85
|
+
return [n];
|
|
86
|
+
const y = i === t.Captured, p = i === t.InProgress, u = i === t.Done, c = (e == null ? void 0 : e.orderFormat) === s.EatIn, g = (e == null ? void 0 : e.orderFormat) === s.TakeAway, O = (e == null ? void 0 : e.orderFormat) === s.TableOrder, f = (e == null ? void 0 : e.orderFormat) === s.Delivery;
|
|
87
|
+
if (y)
|
|
88
|
+
return O && !o ? ["yourOrderWillArriveAtYourTable"] : f ? d ? ["modifiedDeliveryStartTime"] : ["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"] : d ? ["modifiedPickUpTime"] : ["yourOrderHasBeenAcceptedPickupTime"];
|
|
89
|
+
if (p) {
|
|
90
|
+
if (f)
|
|
91
|
+
return d ? ["modifiedDeliveryStartTime"] : ["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"];
|
|
92
|
+
if (c || g) {
|
|
93
|
+
if (r.ready === r.all)
|
|
94
|
+
return ["yourOrderIsReadyToCollect"];
|
|
95
|
+
if (r.done === r.all)
|
|
96
|
+
return ["yourOrderHasBeenCompleted"];
|
|
97
|
+
}
|
|
98
|
+
return O ? r.ready === r.all ? o ? ["yourOrderIsReadyToCollect"] : ["yourOrderWillArriveAtYourTable"] : r.done === r.all ? o ? ["yourOrderHasBeenCompleted"] : ["yourOrderWillArriveAtYourTable"] : d ? ["modifiedPickUpTime"] : o ? ["yourOrderIsBeingPrepared"] : ["yourOrderWillArriveAtYourTable"] : d ? ["modifiedPickUpTime"] : ["yourOrderIsBeingPrepared"];
|
|
98
99
|
}
|
|
100
|
+
if (u)
|
|
101
|
+
return c || g ? ["yourOrderHasBeenCompleted"] : f ? ["deliveryWasCompleted"] : ["yourOrderHasBeenCompleted"];
|
|
99
102
|
throw new Error("Could not resolve translation key in getTranslationKey()");
|
|
100
103
|
}
|
|
101
104
|
const h = {
|
|
@@ -134,6 +137,10 @@ const h = {
|
|
|
134
137
|
title: "Your pickup time was modified",
|
|
135
138
|
message: "Pickup time: 00:00"
|
|
136
139
|
}),
|
|
140
|
+
yourOrderHasBeenAcceptedEstimatedDeliveryStartTime: () => ({
|
|
141
|
+
title: "Your order has been accepted",
|
|
142
|
+
message: "Estimated delivery start time: 00:00"
|
|
143
|
+
}),
|
|
137
144
|
yourOrderHasBeenAcceptedEstimatedTime: () => ({
|
|
138
145
|
title: "Your order has been accepted",
|
|
139
146
|
message: "Estimated time: 00:00"
|
|
@@ -142,10 +149,6 @@ const h = {
|
|
|
142
149
|
title: "Your order has been accepted",
|
|
143
150
|
message: "Pickup time: 00:00"
|
|
144
151
|
}),
|
|
145
|
-
yourOrderIsBeingDelivered: () => ({
|
|
146
|
-
title: "Your order is being delivered",
|
|
147
|
-
message: "It will arrive at your door shortly. Enjoy your meal!"
|
|
148
|
-
}),
|
|
149
152
|
deliveryWasCompleted: () => ({
|
|
150
153
|
title: "Your order was completed",
|
|
151
154
|
message: "Enjoy your meal!"
|
|
@@ -163,19 +166,19 @@ const h = {
|
|
|
163
166
|
message: `${e.count} more items are being prepared`
|
|
164
167
|
})
|
|
165
168
|
};
|
|
166
|
-
function w(e,
|
|
167
|
-
const
|
|
169
|
+
function w(e, i, l = h) {
|
|
170
|
+
const o = m(
|
|
168
171
|
(e == null ? void 0 : e.items) ?? []
|
|
169
|
-
), [
|
|
170
|
-
all:
|
|
171
|
-
ready:
|
|
172
|
-
done:
|
|
173
|
-
}),
|
|
174
|
-
if (!
|
|
172
|
+
), [d, r] = B(e, i, {
|
|
173
|
+
all: o.all.length,
|
|
174
|
+
ready: o.ready.length,
|
|
175
|
+
done: o.done.length
|
|
176
|
+
}), n = l[d]({ key: d, meta: r });
|
|
177
|
+
if (!n)
|
|
175
178
|
throw new Error("Could not resolve translation in getOrderStatusTexts()");
|
|
176
|
-
return [
|
|
179
|
+
return [n, d];
|
|
177
180
|
}
|
|
178
181
|
export {
|
|
179
|
-
|
|
182
|
+
C as TranslationKey,
|
|
180
183
|
w as default
|
|
181
184
|
};
|