@ancon/wildcat-utils 1.20.1 → 1.20.3
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.
|
@@ -45,17 +45,21 @@ declare enum TranslationKey {
|
|
|
45
45
|
}
|
|
46
46
|
declare type TranslationsWithMeta = {
|
|
47
47
|
[TranslationKey.MultipleItemsAreReadyToCollect]: ({ meta, }: {
|
|
48
|
+
key: TranslationKey;
|
|
48
49
|
meta: {
|
|
49
50
|
count: number;
|
|
50
51
|
};
|
|
51
52
|
}) => Translation;
|
|
52
|
-
[TranslationKey.EnjoyMealWhileOtherItemsBeingPrepared]: ({ meta, }: {
|
|
53
|
+
[TranslationKey.EnjoyMealWhileOtherItemsBeingPrepared]: ({ key, meta, }: {
|
|
54
|
+
key: TranslationKey;
|
|
53
55
|
meta: {
|
|
54
56
|
count: number;
|
|
55
57
|
};
|
|
56
58
|
}) => Translation;
|
|
57
59
|
};
|
|
58
|
-
declare type TranslatedTexts = Record<Exclude<TranslationKey, keyof TranslationsWithMeta>, (
|
|
60
|
+
declare type TranslatedTexts = Record<Exclude<TranslationKey, keyof TranslationsWithMeta>, ({ key }: {
|
|
61
|
+
key: TranslationKey;
|
|
62
|
+
}) => Translation> & TranslationsWithMeta;
|
|
59
63
|
declare function getOrderStatusTexts(checkout: CheckoutSummary, options: Options, texts?: TranslatedTexts): [Translation, TranslationKey];
|
|
60
64
|
export { TranslationKey };
|
|
61
65
|
export default getOrderStatusTexts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@ancon/wildcat-types"),O=require("./getCheckoutItemsMappedByTicketItemStatus.js");var n=(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.YourOrderIsReady="yourOrderIsReady",e.DeliveryWasCompleted="deliveryWasCompleted",e.OneItemIsReadyToCollect="oneItemIsReadyToCollect",e.MultipleItemsAreReadyToCollect="multipleItemsAreReadyToCollect",e.EnjoyMealWhileOtherItemsBeingPrepared="enjoyMealWhileOtherItemsBeingPrepared",e))(n||{});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:
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@ancon/wildcat-types"),O=require("./getCheckoutItemsMappedByTicketItemStatus.js");var n=(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.YourOrderIsReady="yourOrderIsReady",e.DeliveryWasCompleted="deliveryWasCompleted",e.OneItemIsReadyToCollect="oneItemIsReadyToCollect",e.MultipleItemsAreReadyToCollect="multipleItemsAreReadyToCollect",e.EnjoyMealWhileOtherItemsBeingPrepared="enjoyMealWhileOtherItemsBeingPrepared",e))(n||{});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 I(e){switch(e){case r.TicketStatus.Pending:case r.TicketStatus.PendingAccept:return"processingPayment";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 h({orderFormat:e},{checkoutStatus:d,ticketStatus:s,useMarkAsPickedUp:o,pickupTimeUpdated:i},t){if(o&&t.ready>0)return t.ready<2?["oneItemIsReadyToCollect"]:["multipleItemsAreReadyToCollect",{count:t.ready}];if(o&&t.done>0&&t.done<t.all)return["enjoyMealWhileOtherItemsBeingPrepared",{count:Math.max(0,t.all-t.done-t.ready)}];if(s!=null)return[I(s)];const a=C(d);if(a)return[a];const c=d===r.CheckoutStatus.Captured,y=d===r.CheckoutStatus.InProgress,m=d===r.CheckoutStatus.Canceled,u=e===r.OrderFormat.TableOrder,l=e===r.OrderFormat.Delivery;if(c)return u?["yourOrderWillArriveAtYourTable"]:i&&l?["modifiedDeliveryStartTime"]:i?["modifiedPickUpTime"]:o?["yourOrderHasBeenAcceptedPickupTime"]:["yourOrderHasBeenAcceptedEstimatedTime"];if(y)return i&&l?["modifiedDeliveryStartTime"]:l?["yourOrderIsBeingDelivered"]:i?["modifiedPickUpTime"]:o?["yourOrderHasBeenAcceptedPickupTime"]:["yourOrderHasBeenAcceptedEstimatedTime"];if(m){const p=e===r.OrderFormat.EatIn,g=e===r.OrderFormat.TakeAway;if(p||g)return o?["yourOrderHasBeenCompleted"]:["yourOrderIsReady"];if(l)return["deliveryWasCompleted"];if(u)return o?["yourOrderIsReadyToCollect"]:["yourOrderWillArriveAtYourTable"]}throw new Error("Could not resolve translation key in getTranslationKey()")}const f={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!"}),yourOrderIsReady:()=>({title:"Your order is ready",message:"Enjoy your meal!"}),deliveryWasCompleted:()=>({title:"Your order was completed",message:"Enjoy your meal!"}),oneItemIsReadyToCollect:()=>({title:"One item is ready to pick up!"}),multipleItemsAreReadyToCollect:()=>({title:"Multiple items are ready to pick up!"}),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 T(e,d,s=f){const o=O(e.items),[i,t]=h(e,d,{all:o.all.length,ready:o.ready.length,done:o.done.length}),a=s[i]({key:i,meta:t});if(!a)throw new Error("Could not resolve translation in getOrderStatusTexts()");return[a,i]}exports.TranslationKey=n;exports.default=T;
|
|
@@ -15,12 +15,10 @@ function C(e) {
|
|
|
15
15
|
case o.ReadyToCollect:
|
|
16
16
|
return "yourOrderIsReadyToCollect";
|
|
17
17
|
default:
|
|
18
|
-
|
|
19
|
-
`Unhandled checkout status "${e}" in getTranslationKeyByCheckoutStatus()`
|
|
20
|
-
);
|
|
18
|
+
return null;
|
|
21
19
|
}
|
|
22
20
|
}
|
|
23
|
-
function
|
|
21
|
+
function T(e) {
|
|
24
22
|
switch (e) {
|
|
25
23
|
case a.Pending:
|
|
26
24
|
case a.PendingAccept:
|
|
@@ -39,7 +37,7 @@ function h(e) {
|
|
|
39
37
|
);
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
function
|
|
40
|
+
function h({ orderFormat: e }, {
|
|
43
41
|
checkoutStatus: d,
|
|
44
42
|
ticketStatus: l,
|
|
45
43
|
useMarkAsPickedUp: t,
|
|
@@ -56,7 +54,7 @@ function T({ orderFormat: e }, {
|
|
|
56
54
|
{ count: Math.max(0, r.all - r.done - r.ready) }
|
|
57
55
|
];
|
|
58
56
|
if (l != null)
|
|
59
|
-
return [
|
|
57
|
+
return [T(l)];
|
|
60
58
|
const s = C(d);
|
|
61
59
|
if (s)
|
|
62
60
|
return [s];
|
|
@@ -144,11 +142,11 @@ const B = {
|
|
|
144
142
|
})
|
|
145
143
|
};
|
|
146
144
|
function Y(e, d, l = B) {
|
|
147
|
-
const t = I(e.items), [i, r] =
|
|
145
|
+
const t = I(e.items), [i, r] = h(e, d, {
|
|
148
146
|
all: t.all.length,
|
|
149
147
|
ready: t.ready.length,
|
|
150
148
|
done: t.done.length
|
|
151
|
-
}), s = l[i]({ meta: r });
|
|
149
|
+
}), s = l[i]({ key: i, meta: r });
|
|
152
150
|
if (!s)
|
|
153
151
|
throw new Error("Could not resolve translation in getOrderStatusTexts()");
|
|
154
152
|
return [s, i];
|