@ancon/wildcat-utils 1.50.7 → 1.50.9
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";const n=require("@ancon/wildcat-types");function s(i){const t=[],o=[];return i.selectedIngredients.forEach(e=>{e.selected?e.replacementId&&t.push({modification:n.ModificationType.Replace,ingredientId:e.id,replaceId:e.replacementId}):t.push({modification:n.ModificationType.Remove,ingredientId:e.id})}),i.selectedAddons.forEach(e=>{var c;if(e.selectedIngredientId){t.push({addOnGroupId:e.addonId,modification:n.ModificationType.Add,ingredientId:e.selectedIngredientId,quantity:1,freeAmount:e.ingredients.some(d=>d.freeAmount===1)?1:0});return}e.ingredients.forEach(d=>{d.selectedCount&&t.push({addOnGroupId:e.addonId,modification:n.ModificationType.Add,ingredientId:d.id,quantity:d.selectedCount,freeAmount:d.freeAmount})}),(c=e.products)==null||c.forEach(d=>{d.selectedCount&&o.push({variantId:d.selectedVariantId,addOnGroupId:e.addonId,quantity:d.selectedCount,freeAmount:d.freeAmount,unitQuantity:d.selectedCount})})}),{modifications:t,quantity:i.quantity,variantId:i.selectedVariantId,showingPrice:i.selectedVariantShowingPrice,addOnProducts:o}}module.exports=s;
|
|
1
|
+
"use strict";const n=require("@ancon/wildcat-types");function s(i){const t=[],o=[];return i.selectedIngredients.forEach(e=>{e.selected?e.replacementId&&t.push({modification:n.ModificationType.Replace,ingredientId:e.id,replaceId:e.replacementId}):t.push({modification:n.ModificationType.Remove,ingredientId:e.id})}),i.selectedAddons.forEach(e=>{var c;if(e.selectedIngredientId){t.push({addOnGroupId:e.addonId,modification:n.ModificationType.Add,ingredientId:e.selectedIngredientId,quantity:1,freeAmount:e.ingredients.some(d=>d.freeAmount===1)?1:0});return}e.ingredients.forEach(d=>{d.selectedCount&&t.push({addOnGroupId:e.addonId,modification:n.ModificationType.Add,ingredientId:d.id,quantity:d.selectedCount,freeAmount:d.freeAmount})}),(c=e.products)==null||c.forEach(d=>{d.selectedCount&&o.push({variantId:d.selectedVariantId,addOnGroupId:e.addonId,quantity:d.selectedCount,freeAmount:d.freeAmount,unitQuantity:d.selectedCount})})}),{modifications:t,quantity:i.quantity,variantId:i.selectedVariantId,showingPrice:i.selectedVariantShowingPrice,addOnProducts:o,itemType:n.CheckoutItemType.SaleProduct}}module.exports=s;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ModificationType as n } from "@ancon/wildcat-types";
|
|
2
|
-
function
|
|
1
|
+
import { ModificationType as n, CheckoutItemType as s } from "@ancon/wildcat-types";
|
|
2
|
+
function f(t) {
|
|
3
3
|
const i = [], o = [];
|
|
4
4
|
return t.selectedIngredients.forEach((e) => {
|
|
5
5
|
e.selected ? e.replacementId && i.push({
|
|
@@ -11,7 +11,7 @@ function r(t) {
|
|
|
11
11
|
ingredientId: e.id
|
|
12
12
|
});
|
|
13
13
|
}), t.selectedAddons.forEach((e) => {
|
|
14
|
-
var
|
|
14
|
+
var c;
|
|
15
15
|
if (e.selectedIngredientId) {
|
|
16
16
|
i.push({
|
|
17
17
|
addOnGroupId: e.addonId,
|
|
@@ -30,7 +30,7 @@ function r(t) {
|
|
|
30
30
|
quantity: d.selectedCount,
|
|
31
31
|
freeAmount: d.freeAmount
|
|
32
32
|
});
|
|
33
|
-
}), (
|
|
33
|
+
}), (c = e.products) == null || c.forEach((d) => {
|
|
34
34
|
d.selectedCount && o.push({
|
|
35
35
|
variantId: d.selectedVariantId,
|
|
36
36
|
addOnGroupId: e.addonId,
|
|
@@ -44,9 +44,11 @@ function r(t) {
|
|
|
44
44
|
quantity: t.quantity,
|
|
45
45
|
variantId: t.selectedVariantId,
|
|
46
46
|
showingPrice: t.selectedVariantShowingPrice,
|
|
47
|
-
addOnProducts: o
|
|
47
|
+
addOnProducts: o,
|
|
48
|
+
itemType: s.SaleProduct
|
|
49
|
+
// default type, this only changes for upsell items
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
52
|
export {
|
|
51
|
-
|
|
53
|
+
f as default
|
|
52
54
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const y=require("./isWalletTopUpCheckoutItem.js"),I=require("./isGiftCardCheckoutItem.js");require("@ancon/wildcat-types");function i(u,a){const{product:r,quantity:n,modifications:p,upsellGroupId:l,totalPriceInclTax:s,addOnProducts:c,itemType:d}=u;if(y(u)){let e=null;if(a){const t=a;e=JSON.stringify({id:t.id,prepaidWalletNumber:t.prepaidWalletNumber})}return{productType:r.productType,variantType:r.variantType,price:{unitPrice:s.amount},metaData:e,quantity:n,modifications:[],addOnProducts:[],itemType:d}}if(I(u)){let e=null;if(a){const t=a;e=JSON.stringify({draftGiftCardId:t.draftGiftCardId,amount:t.amount,email:t.email,greetingMessage:t.greetingMessage,id:t.id,receivedBy:t.receivedBy,senderEmail:t.senderEmail,sendingBy:t.sendingBy,sms:t.sms})}return{productType:r.productType,variantType:r.variantType,price:{unitPrice:s.amount},metaData:e,quantity:n,modifications:[],addOnProducts:[],itemType:d}}return{variantId:r.variantId,quantity:n,modifications:p.map(e=>({modification:e.modification,ingredientId:e.ingredientId,quantity:e==null?void 0:e.quantity,freeAmount:e==null?void 0:e.freeAmount,addOnGroupId:(e==null?void 0:e.groupId)||void 0,replaceId:e.replaceId||void 0,description:e==null?void 0:e.description})),addOnProducts:c.map(e=>({quantity:e.quantity,freeAmount:e.addOnFreeAmount,variantId:e.product.variantId,unitQuantity:e.quantity,addOnGroupId:e.addOnGroupId})),upsellGroupId:l,itemType:d}}module.exports=i;
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import I from "./isWalletTopUpCheckoutItem.mjs";
|
|
2
|
-
import
|
|
2
|
+
import i from "./isGiftCardCheckoutItem.mjs";
|
|
3
3
|
import "@ancon/wildcat-types";
|
|
4
4
|
function v(u, a) {
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
product: r,
|
|
7
|
+
quantity: n,
|
|
8
|
+
modifications: s,
|
|
9
|
+
upsellGroupId: l,
|
|
10
|
+
totalPriceInclTax: d,
|
|
11
|
+
addOnProducts: y,
|
|
12
|
+
itemType: p
|
|
13
|
+
} = u;
|
|
6
14
|
if (I(u)) {
|
|
7
15
|
let e = null;
|
|
8
16
|
if (a) {
|
|
@@ -19,10 +27,11 @@ function v(u, a) {
|
|
|
19
27
|
metaData: e,
|
|
20
28
|
quantity: n,
|
|
21
29
|
modifications: [],
|
|
22
|
-
addOnProducts: []
|
|
30
|
+
addOnProducts: [],
|
|
31
|
+
itemType: p
|
|
23
32
|
};
|
|
24
33
|
}
|
|
25
|
-
if (
|
|
34
|
+
if (i(u)) {
|
|
26
35
|
let e = null;
|
|
27
36
|
if (a) {
|
|
28
37
|
const t = a;
|
|
@@ -45,13 +54,14 @@ function v(u, a) {
|
|
|
45
54
|
metaData: e,
|
|
46
55
|
quantity: n,
|
|
47
56
|
modifications: [],
|
|
48
|
-
addOnProducts: []
|
|
57
|
+
addOnProducts: [],
|
|
58
|
+
itemType: p
|
|
49
59
|
};
|
|
50
60
|
}
|
|
51
61
|
return {
|
|
52
62
|
variantId: r.variantId,
|
|
53
63
|
quantity: n,
|
|
54
|
-
modifications:
|
|
64
|
+
modifications: s.map((e) => ({
|
|
55
65
|
modification: e.modification,
|
|
56
66
|
ingredientId: e.ingredientId,
|
|
57
67
|
quantity: e == null ? void 0 : e.quantity,
|
|
@@ -60,14 +70,15 @@ function v(u, a) {
|
|
|
60
70
|
replaceId: e.replaceId || void 0,
|
|
61
71
|
description: e == null ? void 0 : e.description
|
|
62
72
|
})),
|
|
63
|
-
addOnProducts:
|
|
73
|
+
addOnProducts: y.map((e) => ({
|
|
64
74
|
quantity: e.quantity,
|
|
65
75
|
freeAmount: e.addOnFreeAmount,
|
|
66
76
|
variantId: e.product.variantId,
|
|
67
77
|
unitQuantity: e.quantity,
|
|
68
78
|
addOnGroupId: e.addOnGroupId
|
|
69
79
|
})),
|
|
70
|
-
upsellGroupId:
|
|
80
|
+
upsellGroupId: l,
|
|
81
|
+
itemType: p
|
|
71
82
|
};
|
|
72
83
|
}
|
|
73
84
|
export {
|
package/checkout/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CheckoutRequestItemUnitPrice, ModificationType, ProductType, VariantType } from '@ancon/wildcat-types';
|
|
1
|
+
import { CheckoutItemType, CheckoutRequestItemUnitPrice, ModificationType, ProductType, VariantType } from '@ancon/wildcat-types';
|
|
2
2
|
export declare type CheckoutRequestItemModification = {
|
|
3
3
|
modification: ModificationType;
|
|
4
4
|
ingredientId: string;
|
|
@@ -26,5 +26,6 @@ export declare type CheckoutRequestItem = {
|
|
|
26
26
|
showingPrice?: number;
|
|
27
27
|
price?: CheckoutRequestItemUnitPrice;
|
|
28
28
|
metaData?: string | null;
|
|
29
|
+
itemType?: CheckoutItemType;
|
|
29
30
|
};
|
|
30
31
|
export declare type CheckoutItemComparisonCandidate = Pick<CheckoutRequestItem, 'variantId' | 'modifications' | 'upsellGroupId'>;
|