@ancon/wildcat-utils 1.20.12 → 1.20.13
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.
|
@@ -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"),O=require("./getCheckoutItemsMappedByTicketItemStatus.js");var p=(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.YourOrderHasBeenAcceptedEstimatedTime="yourOrderHasBeenAcceptedEstimatedTime",e.YourOrderHasBeenAcceptedPickupTime="yourOrderHasBeenAcceptedPickupTime",e.YourOrderIsBeingDelivered="yourOrderIsBeingDelivered",e.DeliveryWasCompleted="deliveryWasCompleted",e.OneItemIsReadyToCollect="oneItemIsReadyToCollect",e.MultipleItemsAreReadyToCollect="multipleItemsAreReadyToCollect",e.EnjoyMealWhileOtherItemsBeingPrepared="enjoyMealWhileOtherItemsBeingPrepared",e))(p||{});function m(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 f(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 C(e,{checkoutStatus:o,ticketStatus:d}){const a=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery,i=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway;if(a||i)return!1;const t=o!=null,s=d!=null;if(t){const l=o===r.CheckoutStatus.Captured,n=o===r.CheckoutStatus.InProgress;return l||n}if(s){const l=d===r.TicketStatus.Preparing,n=d===r.TicketStatus.Ready;return l||n}return!1}function h(e,{checkoutStatus:o,ticketStatus:d,useMarkAsPickedUp:a,pickupTimeUpdated:i},t){if(C(e,{checkoutStatus:o,ticketStatus: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(d!=null)return[f(d)];const s=m(o);if(s)return[s];const l=o===r.CheckoutStatus.Captured,n=o===r.CheckoutStatus.InProgress,g=o===r.CheckoutStatus.Done,c=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder,u=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery;if(l)return c&&!a?["yourOrderWillArriveAtYourTable"]:u?i?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedTime"]:i?["modifiedPickUpTime"]:["yourOrderHasBeenAcceptedPickupTime"];if(n){const y=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway;return u?i?["modifiedDeliveryStartTime"]:["yourOrderIsBeingDelivered"]:y&&(t.ready===t.all||t.done===t.all)?["yourOrderIsReadyToCollect"]:i?["modifiedPickUpTime"]:["yourOrderIsBeingPrepared"]}if(g){if((e==null?void 0:e.orderFormat)===r.OrderFormat.EatIn)return["yourOrderHasBeenCompleted"];if(u)return["deliveryWasCompleted"];if(c)return a?["yourOrderIsReadyToCollect"]:["yourOrderWillArriveAtYourTable"]}throw new Error("Could not resolve translation key in getTranslationKey()")}const T={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"}),yourOrderHasBeenAcceptedEstimatedTime:()=>({title:"Your order has been accepted",message:"Estimated time: 00:00"}),yourOrderHasBeenAcceptedPickupTime:()=>({title:"Your order has been accepted",message:"Pickup time: 00:00"}),yourOrderIsBeingDelivered:()=>({title:"Your order is being delivered",message:"It will arrive at your door shortly. Enjoy your meal!"}),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,o,d=T){const a=O((e==null?void 0:e.items)??[]),[i,t]=h(e,o,{all:a.all.length,ready:a.ready.length,done:a.done.length}),s=d[i]({key:i,meta:t});if(!s)throw new Error("Could not resolve translation in getOrderStatusTexts()");return[s,i]}exports.TranslationKey=p;exports.default=I;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CheckoutStatus as t, OrderFormat as n, TicketStatus as
|
|
2
|
-
import
|
|
3
|
-
var
|
|
4
|
-
function
|
|
1
|
+
import { CheckoutStatus as t, OrderFormat as n, TicketStatus as a } from "@ancon/wildcat-types";
|
|
2
|
+
import m from "./getCheckoutItemsMappedByTicketItemStatus.mjs";
|
|
3
|
+
var O = /* @__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.YourOrderHasBeenAcceptedEstimatedTime = "yourOrderHasBeenAcceptedEstimatedTime", e.YourOrderHasBeenAcceptedPickupTime = "yourOrderHasBeenAcceptedPickupTime", e.YourOrderIsBeingDelivered = "yourOrderIsBeingDelivered", e.DeliveryWasCompleted = "deliveryWasCompleted", e.OneItemIsReadyToCollect = "oneItemIsReadyToCollect", e.MultipleItemsAreReadyToCollect = "multipleItemsAreReadyToCollect", e.EnjoyMealWhileOtherItemsBeingPrepared = "enjoyMealWhileOtherItemsBeingPrepared", e))(O || {});
|
|
4
|
+
function I(e) {
|
|
5
5
|
switch (e) {
|
|
6
6
|
case t.Created:
|
|
7
7
|
case t.Ready:
|
|
@@ -18,18 +18,18 @@ function P(e) {
|
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function P(e) {
|
|
22
22
|
switch (e) {
|
|
23
|
-
case
|
|
24
|
-
case
|
|
23
|
+
case a.Pending:
|
|
24
|
+
case a.PendingAccept:
|
|
25
25
|
return "yourOrderIsBeingProcessed";
|
|
26
|
-
case
|
|
26
|
+
case a.Preparing:
|
|
27
27
|
return "yourOrderIsBeingPrepared";
|
|
28
|
-
case
|
|
28
|
+
case a.Ready:
|
|
29
29
|
return "yourOrderIsReadyToCollect";
|
|
30
|
-
case
|
|
30
|
+
case a.Closed:
|
|
31
31
|
return "yourOrderHasBeenCompleted";
|
|
32
|
-
case
|
|
32
|
+
case a.Canceled:
|
|
33
33
|
return "yourOrderWasCancelled";
|
|
34
34
|
default:
|
|
35
35
|
throw new Error(
|
|
@@ -37,31 +37,31 @@ function C(e) {
|
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function C(e, {
|
|
41
41
|
checkoutStatus: o,
|
|
42
42
|
ticketStatus: d
|
|
43
43
|
}) {
|
|
44
44
|
const l = (e == null ? void 0 : e.orderFormat) === n.Delivery, i = (e == null ? void 0 : e.orderFormat) === n.TakeAway;
|
|
45
45
|
if (l || i)
|
|
46
46
|
return !1;
|
|
47
|
-
const r = o != null,
|
|
47
|
+
const r = o != null, s = d != null;
|
|
48
48
|
if (r) {
|
|
49
49
|
const c = o === t.Captured, u = o === t.InProgress;
|
|
50
50
|
return c || u;
|
|
51
51
|
}
|
|
52
|
-
if (
|
|
53
|
-
const c = d ===
|
|
52
|
+
if (s) {
|
|
53
|
+
const c = d === a.Preparing, u = d === a.Ready;
|
|
54
54
|
return c || u;
|
|
55
55
|
}
|
|
56
56
|
return !1;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function T(e, {
|
|
59
59
|
checkoutStatus: o,
|
|
60
60
|
ticketStatus: d,
|
|
61
61
|
useMarkAsPickedUp: l,
|
|
62
62
|
pickupTimeUpdated: i
|
|
63
63
|
}, r) {
|
|
64
|
-
if (
|
|
64
|
+
if (C(e, {
|
|
65
65
|
checkoutStatus: o,
|
|
66
66
|
ticketStatus: d
|
|
67
67
|
})) {
|
|
@@ -77,19 +77,20 @@ function h(e, {
|
|
|
77
77
|
];
|
|
78
78
|
}
|
|
79
79
|
if (d != null)
|
|
80
|
-
return [
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
return [
|
|
84
|
-
const c = o === t.Captured, u = o === t.InProgress,
|
|
80
|
+
return [P(d)];
|
|
81
|
+
const s = I(o);
|
|
82
|
+
if (s)
|
|
83
|
+
return [s];
|
|
84
|
+
const c = o === t.Captured, u = o === t.InProgress, f = o === t.Done, p = (e == null ? void 0 : e.orderFormat) === n.TableOrder, y = (e == null ? void 0 : e.orderFormat) === n.Delivery;
|
|
85
85
|
if (c)
|
|
86
86
|
return p && !l ? ["yourOrderWillArriveAtYourTable"] : y ? i ? ["modifiedDeliveryStartTime"] : ["yourOrderHasBeenAcceptedEstimatedTime"] : i ? ["modifiedPickUpTime"] : ["yourOrderHasBeenAcceptedPickupTime"];
|
|
87
|
-
if (u)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
if (u) {
|
|
88
|
+
const g = (e == null ? void 0 : e.orderFormat) === n.TakeAway;
|
|
89
|
+
return y ? i ? ["modifiedDeliveryStartTime"] : ["yourOrderIsBeingDelivered"] : g && (r.ready === r.all || r.done === r.all) ? ["yourOrderIsReadyToCollect"] : i ? ["modifiedPickUpTime"] : ["yourOrderIsBeingPrepared"];
|
|
90
|
+
}
|
|
91
|
+
if (f) {
|
|
92
|
+
if ((e == null ? void 0 : e.orderFormat) === n.EatIn)
|
|
93
|
+
return ["yourOrderHasBeenCompleted"];
|
|
93
94
|
if (y)
|
|
94
95
|
return ["deliveryWasCompleted"];
|
|
95
96
|
if (p)
|
|
@@ -97,7 +98,7 @@ function h(e, {
|
|
|
97
98
|
}
|
|
98
99
|
throw new Error("Could not resolve translation key in getTranslationKey()");
|
|
99
100
|
}
|
|
100
|
-
const
|
|
101
|
+
const h = {
|
|
101
102
|
yourOrderIsBeingProcessed: () => ({
|
|
102
103
|
title: "Your order is being processed"
|
|
103
104
|
}),
|
|
@@ -162,19 +163,19 @@ const B = {
|
|
|
162
163
|
message: `${e.count} more items are being prepared`
|
|
163
164
|
})
|
|
164
165
|
};
|
|
165
|
-
function
|
|
166
|
-
const l =
|
|
166
|
+
function w(e, o, d = h) {
|
|
167
|
+
const l = m(
|
|
167
168
|
(e == null ? void 0 : e.items) ?? []
|
|
168
|
-
), [i, r] =
|
|
169
|
+
), [i, r] = T(e, o, {
|
|
169
170
|
all: l.all.length,
|
|
170
171
|
ready: l.ready.length,
|
|
171
172
|
done: l.done.length
|
|
172
|
-
}),
|
|
173
|
-
if (!
|
|
173
|
+
}), s = d[i]({ key: i, meta: r });
|
|
174
|
+
if (!s)
|
|
174
175
|
throw new Error("Could not resolve translation in getOrderStatusTexts()");
|
|
175
|
-
return [
|
|
176
|
+
return [s, i];
|
|
176
177
|
}
|
|
177
178
|
export {
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
O as TranslationKey,
|
|
180
|
+
w as default
|
|
180
181
|
};
|