@ancon/wildcat-utils 1.40.1 → 1.40.2
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,4 +1,4 @@
|
|
|
1
|
-
import { CheckoutStatus, OrderFormat, TicketItemStatus, TicketStatus } from '@ancon/wildcat-types';
|
|
1
|
+
import { AttendeePreOrderStatus, CheckoutStatus, OrderFormat, PreOrderStatus, TicketItemStatus, TicketStatus } from '@ancon/wildcat-types';
|
|
2
2
|
declare type CheckoutOrderSummaryItem = {
|
|
3
3
|
ticketItem: {
|
|
4
4
|
status: TicketItemStatus;
|
|
@@ -15,6 +15,12 @@ declare type Options = {
|
|
|
15
15
|
isSkipTicketStatus?: boolean;
|
|
16
16
|
checkoutStatus?: CheckoutStatus;
|
|
17
17
|
ticketStatus?: TicketStatus;
|
|
18
|
+
preOrderOptions?: PreOrderOptions;
|
|
19
|
+
};
|
|
20
|
+
export declare type PreOrderOptions = {
|
|
21
|
+
isHost: boolean;
|
|
22
|
+
preOrderStatus: PreOrderStatus;
|
|
23
|
+
preOrderAttendeeStatus: AttendeePreOrderStatus;
|
|
18
24
|
};
|
|
19
25
|
/** TODO: Rename to CheckoutOrderStatusTranslation */
|
|
20
26
|
declare type Translation = {
|
|
@@ -23,6 +29,8 @@ declare type Translation = {
|
|
|
23
29
|
};
|
|
24
30
|
/** TODO: Rename to CheckoutOrderStatusTranslationKey */
|
|
25
31
|
declare enum TranslationKey {
|
|
32
|
+
OrderConfirmedHostWillApproveAndProcess = "orderConfirmedHostWillApproveAndProcess",
|
|
33
|
+
OrderConfirmedRestaurantAdminWillAcceptSoon = "orderConfirmedRestaurantAdminWillAcceptSoon",
|
|
26
34
|
YourOrderIsBeingProcessed = "yourOrderIsBeingProcessed",
|
|
27
35
|
YourOrderWasCancelled = "yourOrderWasCancelled",
|
|
28
36
|
ProcessingPayment = "processingPayment",
|
|
@@ -1 +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"),C=require("./getCheckoutItemsMappedByTicketItemStatus.js");var O=(e=>(e.OrderConfirmedHostWillApproveAndProcess="orderConfirmedHostWillApproveAndProcess",e.OrderConfirmedRestaurantAdminWillAcceptSoon="orderConfirmedRestaurantAdminWillAcceptSoon",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))(O||{});function h(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 P(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){const{isHost:o,preOrderStatus:i,preOrderAttendeeStatus:d}=e;return i===r.PreOrderStatus.Started&&d===r.AttendeePreOrderStatus.Confirmed?o?"orderConfirmedRestaurantAdminWillAcceptSoon":"orderConfirmedHostWillApproveAndProcess":null}function A(e,{checkoutStatus:o,ticketStatus:i,customersFetchTableOrders:d}){const a=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery,l=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,t=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder;if(a||l||t&&!d)return!1;const s=o!=null,c=i!=null;if(s){const n=o===r.CheckoutStatus.Captured,u=o===r.CheckoutStatus.InProgress;return n||u}if(c){const n=i===r.TicketStatus.Preparing,u=i===r.TicketStatus.Ready;return n||u}return!1}function I(e,{checkoutStatus:o,ticketStatus:i,customersFetchTableOrders:d,pickupTimeUpdated:a,preOrderOptions:l},t){if(t&&A(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[P(i)];if(o===r.CheckoutStatus.Created&&l){const f=T(l);if(f)return[f]}const s=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery,c=h(o,s);if(c)return[c];const n=o===r.CheckoutStatus.Captured,u=o===r.CheckoutStatus.InProgress,g=o===r.CheckoutStatus.Done,p=(e==null?void 0:e.orderFormat)===r.OrderFormat.EatIn,y=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,m=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder;if(n)return m&&!d?["yourOrderWillArriveAtYourTable"]:s?a?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"]:a?["modifiedPickUpTime"]:["yourOrderHasBeenAcceptedPickupTime"];if(u){if(s)return a?["modifiedDeliveryStartTime"]:["yourOrderIsBeingPreparedEstimatedDeliveryStartTime"];if(t&&(p||y)){if(t.ready===t.all)return["yourOrderIsReadyToCollect"];if(t.done===t.all)return["yourOrderHasBeenCompleted"]}if(m){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(g)return p||y?["yourOrderHasBeenCompleted"]:s?["deliveryWasCompleted"]:["yourOrderHasBeenCompleted"];throw new Error("Could not resolve translation key in getTranslationKey()")}const v={orderConfirmedHostWillApproveAndProcess:()=>({title:`Order Confirmed!
|
|
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.`}),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 B(e,o){if(o)return;const i=C(e);return{all:i.all.length,ready:i.ready.length,done:i.done.length}}function S(e,o,i=v){const{isSkipTicketStatus:d}=o,a=B((e==null?void 0:e.items)??[],d),[l,t]=I(e,o,a),s=i[l]({key:l,meta:t});if(!s)throw new Error("Could not resolve translation in getOrderStatusTexts()");return[s,l]}exports.TranslationKey=O;exports.default=S;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
var
|
|
4
|
-
function
|
|
1
|
+
import { CheckoutStatus as o, OrderFormat as u, TicketStatus as s, PreOrderStatus as P, AttendeePreOrderStatus as A } from "@ancon/wildcat-types";
|
|
2
|
+
import I from "./getCheckoutItemsMappedByTicketItemStatus.mjs";
|
|
3
|
+
var v = /* @__PURE__ */ ((e) => (e.OrderConfirmedHostWillApproveAndProcess = "orderConfirmedHostWillApproveAndProcess", e.OrderConfirmedRestaurantAdminWillAcceptSoon = "orderConfirmedRestaurantAdminWillAcceptSoon", 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))(v || {});
|
|
4
|
+
function h(e, t) {
|
|
5
5
|
switch (e) {
|
|
6
6
|
case o.Error:
|
|
7
7
|
return "thereWasAnError";
|
|
@@ -20,7 +20,7 @@ function P(e, t) {
|
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function B(e) {
|
|
24
24
|
switch (e) {
|
|
25
25
|
case s.Pending:
|
|
26
26
|
case s.PendingAccept:
|
|
@@ -39,32 +39,37 @@ function C(e) {
|
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function T(e) {
|
|
43
|
+
const { isHost: t, preOrderStatus: i, preOrderAttendeeStatus: d } = e;
|
|
44
|
+
return i === P.Started && d === A.Confirmed ? t ? "orderConfirmedRestaurantAdminWillAcceptSoon" : "orderConfirmedHostWillApproveAndProcess" : null;
|
|
45
|
+
}
|
|
46
|
+
function w(e, {
|
|
43
47
|
checkoutStatus: t,
|
|
44
48
|
ticketStatus: i,
|
|
45
49
|
customersFetchTableOrders: d
|
|
46
50
|
}) {
|
|
47
|
-
const a = (e == null ? void 0 : e.orderFormat) === u.Delivery,
|
|
48
|
-
if (a ||
|
|
51
|
+
const a = (e == null ? void 0 : e.orderFormat) === u.Delivery, n = (e == null ? void 0 : e.orderFormat) === u.TakeAway, r = (e == null ? void 0 : e.orderFormat) === u.TableOrder;
|
|
52
|
+
if (a || n || r && !d)
|
|
49
53
|
return !1;
|
|
50
|
-
const
|
|
51
|
-
if (
|
|
52
|
-
const c = t === o.Captured,
|
|
53
|
-
return c ||
|
|
54
|
+
const l = t != null, y = i != null;
|
|
55
|
+
if (l) {
|
|
56
|
+
const c = t === o.Captured, p = t === o.InProgress;
|
|
57
|
+
return c || p;
|
|
54
58
|
}
|
|
55
|
-
if (
|
|
56
|
-
const c = i === s.Preparing,
|
|
57
|
-
return c ||
|
|
59
|
+
if (y) {
|
|
60
|
+
const c = i === s.Preparing, p = i === s.Ready;
|
|
61
|
+
return c || p;
|
|
58
62
|
}
|
|
59
63
|
return !1;
|
|
60
64
|
}
|
|
61
|
-
function
|
|
65
|
+
function W(e, {
|
|
62
66
|
checkoutStatus: t,
|
|
63
67
|
ticketStatus: i,
|
|
64
68
|
customersFetchTableOrders: d,
|
|
65
|
-
pickupTimeUpdated: a
|
|
69
|
+
pickupTimeUpdated: a,
|
|
70
|
+
preOrderOptions: n
|
|
66
71
|
}, r) {
|
|
67
|
-
if (r &&
|
|
72
|
+
if (r && w(e, {
|
|
68
73
|
checkoutStatus: t,
|
|
69
74
|
ticketStatus: i,
|
|
70
75
|
customersFetchTableOrders: d
|
|
@@ -84,16 +89,21 @@ function T(e, {
|
|
|
84
89
|
];
|
|
85
90
|
}
|
|
86
91
|
if (i != null)
|
|
87
|
-
return [
|
|
88
|
-
|
|
92
|
+
return [B(i)];
|
|
93
|
+
if (t === o.Created && n) {
|
|
94
|
+
const O = T(n);
|
|
95
|
+
if (O)
|
|
96
|
+
return [O];
|
|
97
|
+
}
|
|
98
|
+
const l = (e == null ? void 0 : e.orderFormat) === u.Delivery, y = h(
|
|
89
99
|
t,
|
|
90
100
|
l
|
|
91
101
|
);
|
|
92
|
-
if (
|
|
93
|
-
return [
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
return
|
|
102
|
+
if (y)
|
|
103
|
+
return [y];
|
|
104
|
+
const c = t === o.Captured, p = t === o.InProgress, C = t === o.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;
|
|
105
|
+
if (c)
|
|
106
|
+
return g && !d ? [
|
|
97
107
|
"yourOrderWillArriveAtYourTable"
|
|
98
108
|
/* YourOrderWillArriveAtYourTable */
|
|
99
109
|
] : l ? a ? [
|
|
@@ -109,7 +119,7 @@ function T(e, {
|
|
|
109
119
|
"yourOrderHasBeenAcceptedPickupTime"
|
|
110
120
|
/* YourOrderHasBeenAcceptedPickupTime */
|
|
111
121
|
];
|
|
112
|
-
if (
|
|
122
|
+
if (p) {
|
|
113
123
|
if (l)
|
|
114
124
|
return a ? [
|
|
115
125
|
"modifiedDeliveryStartTime"
|
|
@@ -118,7 +128,7 @@ function T(e, {
|
|
|
118
128
|
"yourOrderIsBeingPreparedEstimatedDeliveryStartTime"
|
|
119
129
|
/* YourOrderIsBeingPreparedEstimatedDeliveryStartTime */
|
|
120
130
|
];
|
|
121
|
-
if (r && (
|
|
131
|
+
if (r && (m || f)) {
|
|
122
132
|
if (r.ready === r.all)
|
|
123
133
|
return [
|
|
124
134
|
"yourOrderIsReadyToCollect"
|
|
@@ -130,7 +140,7 @@ function T(e, {
|
|
|
130
140
|
/* YourOrderHasBeenCompleted */
|
|
131
141
|
];
|
|
132
142
|
}
|
|
133
|
-
if (
|
|
143
|
+
if (g) {
|
|
134
144
|
if (r) {
|
|
135
145
|
if (r.ready === r.all)
|
|
136
146
|
return d ? [
|
|
@@ -168,8 +178,8 @@ function T(e, {
|
|
|
168
178
|
/* YourOrderIsBeingPrepared */
|
|
169
179
|
];
|
|
170
180
|
}
|
|
171
|
-
if (
|
|
172
|
-
return
|
|
181
|
+
if (C)
|
|
182
|
+
return m || f ? [
|
|
173
183
|
"yourOrderHasBeenCompleted"
|
|
174
184
|
/* YourOrderHasBeenCompleted */
|
|
175
185
|
] : l ? [
|
|
@@ -181,7 +191,16 @@ function T(e, {
|
|
|
181
191
|
];
|
|
182
192
|
throw new Error("Could not resolve translation key in getTranslationKey()");
|
|
183
193
|
}
|
|
184
|
-
const
|
|
194
|
+
const Y = {
|
|
195
|
+
orderConfirmedHostWillApproveAndProcess: () => ({
|
|
196
|
+
title: `Order Confirmed!
|
|
197
|
+
The host will approve and process the pre-order.`,
|
|
198
|
+
message: "Please contact the host if you want to edit your order."
|
|
199
|
+
}),
|
|
200
|
+
orderConfirmedRestaurantAdminWillAcceptSoon: () => ({
|
|
201
|
+
title: `Order Confirmed!
|
|
202
|
+
The restaurant admin will accept your pre-order soon.`
|
|
203
|
+
}),
|
|
185
204
|
yourOrderIsBeingProcessed: () => ({
|
|
186
205
|
title: "Your order is being processed"
|
|
187
206
|
}),
|
|
@@ -258,26 +277,26 @@ const v = {
|
|
|
258
277
|
message: "There was an error with the checkout"
|
|
259
278
|
})
|
|
260
279
|
};
|
|
261
|
-
function
|
|
280
|
+
function E(e, t) {
|
|
262
281
|
if (t)
|
|
263
282
|
return;
|
|
264
|
-
const i =
|
|
283
|
+
const i = I(e);
|
|
265
284
|
return {
|
|
266
285
|
all: i.all.length,
|
|
267
286
|
ready: i.ready.length,
|
|
268
287
|
done: i.done.length
|
|
269
288
|
};
|
|
270
289
|
}
|
|
271
|
-
function
|
|
272
|
-
const { isSkipTicketStatus: d } = t, a =
|
|
290
|
+
function S(e, t, i = Y) {
|
|
291
|
+
const { isSkipTicketStatus: d } = t, a = E(
|
|
273
292
|
(e == null ? void 0 : e.items) ?? [],
|
|
274
293
|
d
|
|
275
|
-
), [
|
|
276
|
-
if (!
|
|
294
|
+
), [n, r] = W(e, t, a), l = i[n]({ key: n, meta: r });
|
|
295
|
+
if (!l)
|
|
277
296
|
throw new Error("Could not resolve translation in getOrderStatusTexts()");
|
|
278
|
-
return [
|
|
297
|
+
return [l, n];
|
|
279
298
|
}
|
|
280
299
|
export {
|
|
281
|
-
|
|
282
|
-
|
|
300
|
+
v as TranslationKey,
|
|
301
|
+
S as default
|
|
283
302
|
};
|