@ancon/wildcat-utils 1.53.0-check-optimizations.1 → 1.53.0
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.
- package/check/getOrganizedCheckItemModifications.d.ts +2 -2
- package/check/getOrganizedCheckItemModifications.js +1 -1
- package/check/getOrganizedCheckItemModifications.mjs +68 -74
- package/check/getUniqueCheckItemModificationId.d.ts +2 -2
- package/check/getUniqueCheckItemModificationId.js +1 -1
- package/check/getUniqueCheckItemModificationId.mjs +5 -5
- package/checkout/getCheckoutItemModifications.js +1 -1
- package/checkout/getCheckoutItemModifications.mjs +9 -8
- package/checkout/getCheckoutProductAddonModifications.js +1 -1
- package/checkout/getCheckoutProductAddonModifications.mjs +7 -6
- package/checkout/index.js +1 -1
- package/checkout/index.mjs +57 -56
- package/currency/getFormattedCurrency.js +1 -1
- package/currency/getFormattedCurrency.mjs +4 -6
- package/currency/index.d.ts +2 -1
- package/currency/index.js +1 -1
- package/currency/index.mjs +5 -3
- package/currency/placeCurrencySymbol.d.ts +8 -0
- package/currency/placeCurrencySymbol.js +1 -0
- package/currency/placeCurrencySymbol.mjs +12 -0
- package/index.js +1 -1
- package/index.mjs +167 -165
- package/multilingual/createLocalizedCheckDetails.d.ts +2 -2
- package/multilingual/createLocalizedCheckDetails.js +1 -1
- package/multilingual/createLocalizedCheckDetails.mjs +27 -31
- package/package.json +6 -1
- package/string/base64Encode.d.ts +6 -1
- package/string/base64Encode.js +1 -1
- package/string/base64Encode.mjs +6 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CheckItem } from '@ancon/wildcat-types';
|
|
2
2
|
import { OrganizedCheckItemModification } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Organizes all check item modifications including addon products into a array for easier visual representation.
|
|
@@ -7,4 +7,4 @@ import { OrganizedCheckItemModification } from './types';
|
|
|
7
7
|
* @param addOnProducts - The list of check item add-on products.
|
|
8
8
|
* @returns An array where the modifications are sorted by their modification kind and positions.
|
|
9
9
|
*/
|
|
10
|
-
export default function getOrganizedCheckItemModifications(currency: string, modifications:
|
|
10
|
+
export default function getOrganizedCheckItemModifications(currency: string, modifications: CheckItem['modifications'], addOnProducts: CheckItem['addOnProducts']): OrganizedCheckItemModification[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const h=require("@ancon/wildcat-types"),M=require("../toString-b771abdf.js"),P=require("../identity-58f9497d.js"),x=require("../_baseIteratee-374c60ca.js"),k=require("../_getTag-3d3032da.js"),$=require("../isObjectLike-963267e9.js"),O=require("./getUniqueCheckItemModificationId.js");require("../_baseIsEqual-7e335f42.js");require("../isObject-361bd834.js");function L(n){return function(i,r,e){for(var d=-1,t=Object(i),o=e(i),c=o.length;c--;){var a=o[n?c:++d];if(r(t[a],a,t)===!1)break}return i}}var E=L();const _=E;function G(n,i){return n&&_(n,i,k.keys)}function Q(n,i){return function(r,e){if(r==null)return r;if(!k.isArrayLike(r))return n(r,e);for(var d=r.length,t=i?d:-1,o=Object(r);(i?t--:++t<d)&&e(o[t],t,o)!==!1;);return r}}var U=Q(G);const Z=U;function z(n,i){var r=-1,e=k.isArrayLike(n)?Array(n.length):[];return Z(n,function(d,t,o){e[++r]=i(d,t,o)}),e}function V(n,i){var r=n.length;for(n.sort(i);r--;)n[r]=n[r].value;return n}function j(n,i){if(n!==i){var r=n!==void 0,e=n===null,d=n===n,t=M.isSymbol(n),o=i!==void 0,c=i===null,a=i===i,u=M.isSymbol(i);if(!c&&!u&&!t&&n>i||t&&o&&a&&!c&&!u||e&&o&&a||!r&&a||!d)return 1;if(!e&&!t&&!u&&n<i||u&&r&&d&&!e&&!t||c&&r&&d||!o&&d||!a)return-1}return 0}function H(n,i,r){for(var e=-1,d=n.criteria,t=i.criteria,o=d.length,c=r.length;++e<o;){var a=j(d[e],t[e]);if(a){if(e>=c)return a;var u=r[e];return a*(u=="desc"?-1:1)}}return n.index-i.index}function J(n,i,r){i.length?i=M.arrayMap(i,function(t){return $.isArray(t)?function(o){return P.baseGet(o,t.length===1?t[0]:t)}:t}):i=[P.identity];var e=-1;i=M.arrayMap(i,k.baseUnary(x.baseIteratee));var d=z(n,function(t,o,c){var a=M.arrayMap(i,function(u){return u(t)});return{criteria:a,index:++e,value:t}});return V(d,function(t,o){return H(t,o,r)})}function C(n,i,r,e){return n==null?[]:($.isArray(i)||(i=i==null?[]:[i]),r=e?void 0:r,$.isArray(r)||(r=r==null?[]:[r]),J(n,i,r))}function K(n,i,r){const{add:e,replace:d,remove:t}=
|
|
1
|
+
"use strict";const h=require("@ancon/wildcat-types"),M=require("../toString-b771abdf.js"),P=require("../identity-58f9497d.js"),x=require("../_baseIteratee-374c60ca.js"),k=require("../_getTag-3d3032da.js"),$=require("../isObjectLike-963267e9.js"),O=require("./getUniqueCheckItemModificationId.js");require("../_baseIsEqual-7e335f42.js");require("../isObject-361bd834.js");function L(n){return function(i,r,e){for(var d=-1,t=Object(i),o=e(i),c=o.length;c--;){var a=o[n?c:++d];if(r(t[a],a,t)===!1)break}return i}}var E=L();const _=E;function G(n,i){return n&&_(n,i,k.keys)}function Q(n,i){return function(r,e){if(r==null)return r;if(!k.isArrayLike(r))return n(r,e);for(var d=r.length,t=i?d:-1,o=Object(r);(i?t--:++t<d)&&e(o[t],t,o)!==!1;);return r}}var U=Q(G);const Z=U;function z(n,i){var r=-1,e=k.isArrayLike(n)?Array(n.length):[];return Z(n,function(d,t,o){e[++r]=i(d,t,o)}),e}function V(n,i){var r=n.length;for(n.sort(i);r--;)n[r]=n[r].value;return n}function j(n,i){if(n!==i){var r=n!==void 0,e=n===null,d=n===n,t=M.isSymbol(n),o=i!==void 0,c=i===null,a=i===i,u=M.isSymbol(i);if(!c&&!u&&!t&&n>i||t&&o&&a&&!c&&!u||e&&o&&a||!r&&a||!d)return 1;if(!e&&!t&&!u&&n<i||u&&r&&d&&!e&&!t||c&&r&&d||!o&&d||!a)return-1}return 0}function H(n,i,r){for(var e=-1,d=n.criteria,t=i.criteria,o=d.length,c=r.length;++e<o;){var a=j(d[e],t[e]);if(a){if(e>=c)return a;var u=r[e];return a*(u=="desc"?-1:1)}}return n.index-i.index}function J(n,i,r){i.length?i=M.arrayMap(i,function(t){return $.isArray(t)?function(o){return P.baseGet(o,t.length===1?t[0]:t)}:t}):i=[P.identity];var e=-1;i=M.arrayMap(i,k.baseUnary(x.baseIteratee));var d=z(n,function(t,o,c){var a=M.arrayMap(i,function(u){return u(t)});return{criteria:a,index:++e,value:t}});return V(d,function(t,o){return H(t,o,r)})}function C(n,i,r,e){return n==null?[]:($.isArray(i)||(i=i==null?[]:[i]),r=e?void 0:r,$.isArray(r)||(r=r==null?[]:[r]),J(n,i,r))}function K(n,i,r){const{add:e,replace:d,remove:t}=i.reduce((a,u)=>{const{modification:A,position:s,freeAmount:f,name:y,quantity:p,cost:g,replacementName:T}=u,m=g===0;if(u.modification===h.ModificationType.Add){(f>0||m)&&a.add.push({id:O(u,"-free"),modificationType:A,name:y,freeAmount:m?p:f,quantity:m?p:f,currency:n,position:s,cost:0});const q=p-f;q>0&&!m&&a.add.push({id:O(u),modificationType:A,name:y,quantity:q,freeAmount:0,currency:n,position:s,cost:g*q})}return u.modification===h.ModificationType.Replace&&a.replace.push({id:O(u),modificationType:A,name:y,replacementName:T,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),u.modification===h.ModificationType.Remove&&a.remove.push({id:O(u),modificationType:A,name:y,freeAmount:f,quantity:p,currency:n,position:s,cost:g}),a},{add:[],replace:[],remove:[]}),o=(r||[]).reduce((a,u)=>{const{product:A,addOnFreeAmount:s,quantity:f,addOnPosition:y,addOnGroupId:p,productPriceInclTax:g}=u,{hasVariants:T,variantName:m,productName:q,productId:B,variantId:F}=A,b=g.unitPrice.amount===0;(s>0||b)&&a.push({id:`${p}-${B}-free`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:b?f:s,quantity:b?f:s,currency:n,position:y,cost:0,variantId:F});const w=f-s;return w>0&&!b&&a.push({id:`${p}-${B}`,modificationType:h.ModificationType.Add,name:T?m:q,freeAmount:0,quantity:w,currency:n,position:y,cost:g.unitPrice.amount*w,variantId:F}),a},[]);return[...C([...e,...o],["position"],["asc"]),...C(d,["position"],["asc"]),...C(t,["position"],["asc"])]}module.exports=K;
|
|
@@ -8,10 +8,10 @@ import T from "./getUniqueCheckItemModificationId.mjs";
|
|
|
8
8
|
import "../_baseIsEqual-4ee44a4c.mjs";
|
|
9
9
|
import "../isObject-b8638513.mjs";
|
|
10
10
|
function U(n) {
|
|
11
|
-
return function(i, t,
|
|
12
|
-
for (var
|
|
13
|
-
var
|
|
14
|
-
if (t(r[
|
|
11
|
+
return function(i, t, a) {
|
|
12
|
+
for (var e = -1, r = Object(i), u = a(i), f = u.length; f--; ) {
|
|
13
|
+
var o = u[n ? f : ++e];
|
|
14
|
+
if (t(r[o], o, r) === !1)
|
|
15
15
|
break;
|
|
16
16
|
}
|
|
17
17
|
return i;
|
|
@@ -23,12 +23,12 @@ function V(n, i) {
|
|
|
23
23
|
return n && z(n, i, L);
|
|
24
24
|
}
|
|
25
25
|
function H(n, i) {
|
|
26
|
-
return function(t,
|
|
26
|
+
return function(t, a) {
|
|
27
27
|
if (t == null)
|
|
28
28
|
return t;
|
|
29
29
|
if (!P(t))
|
|
30
|
-
return n(t,
|
|
31
|
-
for (var
|
|
30
|
+
return n(t, a);
|
|
31
|
+
for (var e = t.length, r = i ? e : -1, u = Object(t); (i ? r-- : ++r < e) && a(u[r], r, u) !== !1; )
|
|
32
32
|
;
|
|
33
33
|
return t;
|
|
34
34
|
};
|
|
@@ -36,10 +36,10 @@ function H(n, i) {
|
|
|
36
36
|
var J = H(V);
|
|
37
37
|
const K = J;
|
|
38
38
|
function W(n, i) {
|
|
39
|
-
var t = -1,
|
|
40
|
-
return K(n, function(
|
|
41
|
-
|
|
42
|
-
}),
|
|
39
|
+
var t = -1, a = P(n) ? Array(n.length) : [];
|
|
40
|
+
return K(n, function(e, r, u) {
|
|
41
|
+
a[++t] = i(e, r, u);
|
|
42
|
+
}), a;
|
|
43
43
|
}
|
|
44
44
|
function X(n, i) {
|
|
45
45
|
var t = n.length;
|
|
@@ -49,22 +49,22 @@ function X(n, i) {
|
|
|
49
49
|
}
|
|
50
50
|
function Y(n, i) {
|
|
51
51
|
if (n !== i) {
|
|
52
|
-
var t = n !== void 0,
|
|
53
|
-
if (!f && !
|
|
52
|
+
var t = n !== void 0, a = n === null, e = n === n, r = F(n), u = i !== void 0, f = i === null, o = i === i, d = F(i);
|
|
53
|
+
if (!f && !d && !r && n > i || r && u && o && !f && !d || a && u && o || !t && o || !e)
|
|
54
54
|
return 1;
|
|
55
|
-
if (!
|
|
55
|
+
if (!a && !r && !d && n < i || d && t && e && !a && !r || f && t && e || !u && e || !o)
|
|
56
56
|
return -1;
|
|
57
57
|
}
|
|
58
58
|
return 0;
|
|
59
59
|
}
|
|
60
60
|
function _(n, i, t) {
|
|
61
|
-
for (var
|
|
62
|
-
var
|
|
63
|
-
if (
|
|
64
|
-
if (
|
|
65
|
-
return
|
|
66
|
-
var
|
|
67
|
-
return
|
|
61
|
+
for (var a = -1, e = n.criteria, r = i.criteria, u = e.length, f = t.length; ++a < u; ) {
|
|
62
|
+
var o = Y(e[a], r[a]);
|
|
63
|
+
if (o) {
|
|
64
|
+
if (a >= f)
|
|
65
|
+
return o;
|
|
66
|
+
var d = t[a];
|
|
67
|
+
return o * (d == "desc" ? -1 : 1);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
return n.index - i.index;
|
|
@@ -75,110 +75,104 @@ function j(n, i, t) {
|
|
|
75
75
|
return E(u, r.length === 1 ? r[0] : r);
|
|
76
76
|
} : r;
|
|
77
77
|
}) : i = [x];
|
|
78
|
-
var
|
|
78
|
+
var a = -1;
|
|
79
79
|
i = q(i, Q(G));
|
|
80
|
-
var
|
|
81
|
-
var
|
|
82
|
-
return
|
|
80
|
+
var e = W(n, function(r, u, f) {
|
|
81
|
+
var o = q(i, function(d) {
|
|
82
|
+
return d(r);
|
|
83
83
|
});
|
|
84
|
-
return { criteria:
|
|
84
|
+
return { criteria: o, index: ++a, value: r };
|
|
85
85
|
});
|
|
86
|
-
return X(
|
|
86
|
+
return X(e, function(r, u) {
|
|
87
87
|
return _(r, u, t);
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
function C(n, i, t,
|
|
91
|
-
return n == null ? [] : ($(i) || (i = i == null ? [] : [i]), t =
|
|
90
|
+
function C(n, i, t, a) {
|
|
91
|
+
return n == null ? [] : ($(i) || (i = i == null ? [] : [i]), t = a ? void 0 : t, $(t) || (t = t == null ? [] : [t]), j(n, i, t));
|
|
92
92
|
}
|
|
93
93
|
function rn(n, i, t) {
|
|
94
|
-
const { add:
|
|
95
|
-
(
|
|
94
|
+
const { add: a, replace: e, remove: r } = i.reduce(
|
|
95
|
+
(o, d) => {
|
|
96
96
|
const {
|
|
97
97
|
modification: h,
|
|
98
|
-
position:
|
|
99
|
-
freeAmount:
|
|
100
|
-
name: m
|
|
98
|
+
position: p,
|
|
99
|
+
freeAmount: c,
|
|
100
|
+
name: m,
|
|
101
101
|
quantity: s,
|
|
102
102
|
cost: g,
|
|
103
103
|
replacementName: O
|
|
104
|
-
} =
|
|
105
|
-
if (
|
|
106
|
-
(
|
|
107
|
-
id: T(
|
|
104
|
+
} = d, A = g === 0;
|
|
105
|
+
if (d.modification === y.Add) {
|
|
106
|
+
(c > 0 || A) && o.add.push({
|
|
107
|
+
id: T(d, "-free"),
|
|
108
108
|
modificationType: h,
|
|
109
109
|
name: m,
|
|
110
|
-
freeAmount: A ? s :
|
|
111
|
-
quantity: A ? s :
|
|
110
|
+
freeAmount: A ? s : c,
|
|
111
|
+
quantity: A ? s : c,
|
|
112
112
|
currency: n,
|
|
113
|
-
position:
|
|
113
|
+
position: p,
|
|
114
114
|
cost: 0
|
|
115
115
|
});
|
|
116
|
-
const b = s -
|
|
117
|
-
b > 0 && !A &&
|
|
118
|
-
id: T(
|
|
116
|
+
const b = s - c;
|
|
117
|
+
b > 0 && !A && o.add.push({
|
|
118
|
+
id: T(d),
|
|
119
119
|
modificationType: h,
|
|
120
120
|
name: m,
|
|
121
121
|
quantity: b,
|
|
122
122
|
freeAmount: 0,
|
|
123
123
|
currency: n,
|
|
124
|
-
position:
|
|
124
|
+
position: p,
|
|
125
125
|
cost: g * b
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
|
-
return
|
|
129
|
-
id: T(
|
|
128
|
+
return d.modification === y.Replace && o.replace.push({
|
|
129
|
+
id: T(d),
|
|
130
130
|
modificationType: h,
|
|
131
131
|
name: m,
|
|
132
132
|
replacementName: O,
|
|
133
|
-
freeAmount:
|
|
133
|
+
freeAmount: c,
|
|
134
134
|
quantity: s,
|
|
135
135
|
currency: n,
|
|
136
|
-
position:
|
|
136
|
+
position: p,
|
|
137
137
|
cost: g
|
|
138
|
-
}),
|
|
139
|
-
id: T(
|
|
138
|
+
}), d.modification === y.Remove && o.remove.push({
|
|
139
|
+
id: T(d),
|
|
140
140
|
modificationType: h,
|
|
141
141
|
name: m,
|
|
142
|
-
freeAmount:
|
|
142
|
+
freeAmount: c,
|
|
143
143
|
quantity: s,
|
|
144
144
|
currency: n,
|
|
145
|
-
position:
|
|
145
|
+
position: p,
|
|
146
146
|
cost: g
|
|
147
|
-
}),
|
|
147
|
+
}), o;
|
|
148
148
|
},
|
|
149
149
|
{
|
|
150
150
|
add: [],
|
|
151
151
|
replace: [],
|
|
152
152
|
remove: []
|
|
153
153
|
}
|
|
154
|
-
), u = (t
|
|
154
|
+
), u = (t || []).reduce((o, d) => {
|
|
155
155
|
const {
|
|
156
156
|
product: h,
|
|
157
|
-
|
|
158
|
-
quantity:
|
|
159
|
-
|
|
157
|
+
addOnFreeAmount: p,
|
|
158
|
+
quantity: c,
|
|
159
|
+
addOnPosition: m,
|
|
160
160
|
addOnGroupId: s,
|
|
161
161
|
productPriceInclTax: g
|
|
162
|
-
} =
|
|
163
|
-
|
|
164
|
-
variantName: A = "",
|
|
165
|
-
productName: b = "",
|
|
166
|
-
productId: w,
|
|
167
|
-
variantId: B
|
|
168
|
-
} = h ?? {}, M = g.unitPrice === 0;
|
|
169
|
-
(c > 0 || M) && a.push({
|
|
162
|
+
} = d, { hasVariants: O, variantName: A, productName: b, productId: w, variantId: B } = h, M = g.unitPrice.amount === 0;
|
|
163
|
+
(p > 0 || M) && o.push({
|
|
170
164
|
id: `${s}-${w}-free`,
|
|
171
165
|
modificationType: y.Add,
|
|
172
166
|
name: O ? A : b,
|
|
173
|
-
freeAmount: M ?
|
|
174
|
-
quantity: M ?
|
|
167
|
+
freeAmount: M ? c : p,
|
|
168
|
+
quantity: M ? c : p,
|
|
175
169
|
currency: n,
|
|
176
170
|
position: m,
|
|
177
171
|
cost: 0,
|
|
178
172
|
variantId: B
|
|
179
173
|
});
|
|
180
|
-
const k =
|
|
181
|
-
return k > 0 && !M &&
|
|
174
|
+
const k = c - p;
|
|
175
|
+
return k > 0 && !M && o.push({
|
|
182
176
|
id: `${s}-${w}`,
|
|
183
177
|
modificationType: y.Add,
|
|
184
178
|
name: O ? A : b,
|
|
@@ -186,13 +180,13 @@ function rn(n, i, t) {
|
|
|
186
180
|
quantity: k,
|
|
187
181
|
currency: n,
|
|
188
182
|
position: m,
|
|
189
|
-
cost: g.unitPrice * k,
|
|
183
|
+
cost: g.unitPrice.amount * k,
|
|
190
184
|
variantId: B
|
|
191
|
-
}),
|
|
185
|
+
}), o;
|
|
192
186
|
}, []);
|
|
193
187
|
return [
|
|
194
|
-
...C([...
|
|
195
|
-
...C(
|
|
188
|
+
...C([...a, ...u], ["position"], ["asc"]),
|
|
189
|
+
...C(e, ["position"], ["asc"]),
|
|
196
190
|
...C(r, ["position"], ["asc"])
|
|
197
191
|
];
|
|
198
192
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CheckItemModification } from '@ancon/wildcat-types';
|
|
2
2
|
/**
|
|
3
3
|
* Generate a unique ID for a Check Item Modification
|
|
4
4
|
* @param modification - Check Item Modification
|
|
5
5
|
* @param suffix - Optional suffix to append to the ID
|
|
6
6
|
* @returns Unique ID string
|
|
7
7
|
*/
|
|
8
|
-
export default function getUniqueCheckItemModificationId(modification:
|
|
8
|
+
export default function getUniqueCheckItemModificationId(modification: CheckItemModification, suffix?: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function
|
|
1
|
+
"use strict";function u(i,e){const{modification:n,ingredientId:o,replaceId:$,addOnGroupId:c,quantity:d,cost:a,freeAmount:r,name:t,replacementName:m,position:p}=i;return`modification-${n}-${o}-${$??0}-${c}-${d}-${a}-${r}-${t}-${m??t}-${p}${e?`-${e}`:""}`}module.exports=u;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function u(n, e) {
|
|
2
2
|
const {
|
|
3
3
|
modification: i,
|
|
4
4
|
ingredientId: o,
|
|
@@ -7,12 +7,12 @@ function p(n, e) {
|
|
|
7
7
|
quantity: d,
|
|
8
8
|
cost: c,
|
|
9
9
|
freeAmount: r,
|
|
10
|
-
name: t
|
|
10
|
+
name: t,
|
|
11
11
|
replacementName: m,
|
|
12
|
-
position:
|
|
12
|
+
position: p
|
|
13
13
|
} = n;
|
|
14
|
-
return `modification-${i}-${o}-${$ ?? 0}-${a
|
|
14
|
+
return `modification-${i}-${o}-${$ ?? 0}-${a}-${d}-${c}-${r}-${t}-${m ?? t}-${p}${e ? `-${e}` : ""}`;
|
|
15
15
|
}
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
u as default
|
|
18
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("@ancon/wildcat-types"),s=require("../currency/getFormattedCurrency.js");require("../currency/placeCurrencySymbol.js");require("../currency/getFormattedCurrencyPostfix.js");function M(e,t){return t?e-t>0?e-t:0:e}function f(e,t,i,r){const n=`${t}x ${e}`,o=M(t,i);if(o){const d=`(${o}x ${s(r.amount,r.currency)})`;return`${n} ${d}`}return n}function y(e){return e.reduce((i,r)=>{const{modification:n,name:o,freeAmount:d,quantity:p,cost:l,replacementName:m,totalCost:u}=r;switch(n){case a.ModificationType.Remove:i.removed.push(o);break;case a.ModificationType.Replace:{const c=`${o} → ${m} (${s(u.amount,u.currency)})`;i.replaced.push(c);break}default:{const c=f(o,p,d,l);i.added.push(c)}}return i},{added:[],removed:[],replaced:[]})}exports.default=y;exports.getAddModificationText=f;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ModificationType as u } from "@ancon/wildcat-types";
|
|
2
2
|
import f from "../currency/getFormattedCurrency.mjs";
|
|
3
|
+
import "../currency/placeCurrencySymbol.mjs";
|
|
3
4
|
import "../currency/getFormattedCurrencyPostfix.mjs";
|
|
4
5
|
function $(t, e) {
|
|
5
6
|
return e ? t - e > 0 ? t - e : 0 : t;
|
|
@@ -15,16 +16,16 @@ function l(t, e, o, r) {
|
|
|
15
16
|
}
|
|
16
17
|
return n;
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function y(t) {
|
|
19
20
|
return t.reduce(
|
|
20
21
|
(o, r) => {
|
|
21
22
|
const {
|
|
22
23
|
modification: n,
|
|
23
24
|
name: i,
|
|
24
25
|
freeAmount: d,
|
|
25
|
-
quantity:
|
|
26
|
-
cost:
|
|
27
|
-
replacementName:
|
|
26
|
+
quantity: m,
|
|
27
|
+
cost: p,
|
|
28
|
+
replacementName: s,
|
|
28
29
|
totalCost: c
|
|
29
30
|
} = r;
|
|
30
31
|
switch (n) {
|
|
@@ -32,7 +33,7 @@ function x(t) {
|
|
|
32
33
|
o.removed.push(i);
|
|
33
34
|
break;
|
|
34
35
|
case u.Replace: {
|
|
35
|
-
const a = `${i} → ${
|
|
36
|
+
const a = `${i} → ${s} (${f(
|
|
36
37
|
c.amount,
|
|
37
38
|
c.currency
|
|
38
39
|
)})`;
|
|
@@ -42,9 +43,9 @@ function x(t) {
|
|
|
42
43
|
default: {
|
|
43
44
|
const a = l(
|
|
44
45
|
i,
|
|
45
|
-
|
|
46
|
+
m,
|
|
46
47
|
d,
|
|
47
|
-
|
|
48
|
+
p
|
|
48
49
|
);
|
|
49
50
|
o.added.push(a);
|
|
50
51
|
}
|
|
@@ -59,6 +60,6 @@ function x(t) {
|
|
|
59
60
|
);
|
|
60
61
|
}
|
|
61
62
|
export {
|
|
62
|
-
|
|
63
|
+
y as default,
|
|
63
64
|
l as getAddModificationText
|
|
64
65
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./getCheckoutItemModifications.js");require("@ancon/wildcat-types");require("../currency/getFormattedCurrency.js");require("../currency/getFormattedCurrencyPostfix.js");function o(
|
|
1
|
+
"use strict";const i=require("./getCheckoutItemModifications.js");require("@ancon/wildcat-types");require("../currency/getFormattedCurrency.js");require("../currency/placeCurrencySymbol.js");require("../currency/getFormattedCurrencyPostfix.js");function o(e){const{unitPrice:t,additionalPrice:n}=e.unitPriceInclTax;return{amount:t.amount+n.amount,currency:t.currency}}function r(e){return e.map(t=>({id:t.id,modificationText:i.getAddModificationText(t.product.name,t.quantity,t.addOnFreeAmount,o(t))}))}module.exports=r;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { getAddModificationText as i } from "./getCheckoutItemModifications.mjs";
|
|
2
2
|
import "@ancon/wildcat-types";
|
|
3
3
|
import "../currency/getFormattedCurrency.mjs";
|
|
4
|
+
import "../currency/placeCurrencySymbol.mjs";
|
|
4
5
|
import "../currency/getFormattedCurrencyPostfix.mjs";
|
|
5
|
-
function r(
|
|
6
|
-
const { unitPrice: t, additionalPrice:
|
|
6
|
+
function r(o) {
|
|
7
|
+
const { unitPrice: t, additionalPrice: n } = o.unitPriceInclTax;
|
|
7
8
|
return {
|
|
8
|
-
amount: t.amount +
|
|
9
|
+
amount: t.amount + n.amount,
|
|
9
10
|
currency: t.currency
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
|
-
function
|
|
13
|
-
return
|
|
13
|
+
function m(o) {
|
|
14
|
+
return o.map((t) => ({
|
|
14
15
|
id: t.id,
|
|
15
16
|
modificationText: i(
|
|
16
17
|
t.product.name,
|
|
@@ -21,5 +22,5 @@ function e(n) {
|
|
|
21
22
|
}));
|
|
22
23
|
}
|
|
23
24
|
export {
|
|
24
|
-
|
|
25
|
+
m as default
|
|
25
26
|
};
|
package/checkout/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./getCheckoutItemModifications.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./getCheckoutItemModifications.js"),r=require("./getCheckoutProductName.js"),e=require("./getCheckoutOrderStatusTexts.js"),o=require("./getCheckoutItemsMappedByTicketItemStatus.js"),c=require("./isCheckoutOrderSummary.js"),i=require("./buildCheckoutRequestItem.js"),s=require("./getCheckoutGrandTotalAmount.js"),a=require("./getCheckoutRequestItemFromCheckoutItem.js"),k=require("./isCheckoutItemsAreEqual.js"),h=require("./checkoutHasWallet.js"),n=require("./getWalletMetaFromCheckout.js"),C=require("./isPreOrderServiceTime.js"),l=require("./isPreOrderCheckout.js"),q=require("./isUpdatingCheckoutAllowed.js"),d=require("./isCheckoutAlreadyPaidStatus.js"),t=require("./getCheckoutPaymentErrorTranslationTexts.js"),g=require("./isDeletingCheckoutAllowed.js"),m=require("./getTotalCheckoutItemsQuantity.js"),_=require("./getCheckoutPenguinLockersMetaData.js"),T=require("./getUniqueCheckoutPenguinDeliveryCodes.js"),p=require("./isWoltDeliveryInProgress.js"),y=require("./isWalletTopUpCheckoutItem.js"),I=require("./isWalletTopUpCheckout.js"),P=require("./getCheckoutWalletTopUpMetaData.js"),M=require("./isGiftCardCheckout.js"),D=require("./isGiftCardCheckoutItem.js"),G=require("./getCheckoutGiftCardMetaData.js"),f=require("./getCheckoutGuestGroupsMetaData.js");require("@ancon/wildcat-types");require("../currency/getFormattedCurrency.js");require("../currency/placeCurrencySymbol.js");require("../currency/getFormattedCurrencyPostfix.js");require("../order/getCheckOrderItemsMappedByTicketItemStatus.js");require("../order/getCheckOrderMinimumStatusTicketItem.js");require("../toString-b771abdf.js");require("../isObjectLike-963267e9.js");require("../_baseIteratee-374c60ca.js");require("../_getTag-3d3032da.js");require("../isObject-361bd834.js");require("../_baseIsEqual-7e335f42.js");require("../identity-58f9497d.js");require("../order/getMultiProductSubProductsTicketItems.js");require("axios");require("../error/isSerializedAPIError.js");exports.getCheckoutGroupedModifications=u.default;exports.getCheckoutProductName=r;exports.TranslationKey=e.TranslationKey;exports.getCheckoutOrderStatusTexts=e.default;exports.getCheckoutItemsMappedByTicketItemStatus=o;exports.isCheckoutOrderSummary=c;exports.buildCheckoutRequestItem=i;exports.getCheckoutGrandTotalAmount=s;exports.getCheckoutRequestItemFromCheckoutItem=a;exports.isCheckoutItemsAreEqual=k;exports.checkoutHasWallet=h;exports.getWalletMetaFromCheckout=n;exports.isPreOrderServiceTime=C;exports.isPreOrderCheckout=l;exports.isUpdatingCheckoutAllowed=q;exports.isCheckoutAlreadyPaidStatus=d;exports.CheckoutPaymentErrorTranslationKey=t.CheckoutPaymentErrorTranslationKey;exports.getCheckoutPaymentErrorTranslationTexts=t.default;exports.isDeletingCheckoutAllowed=g;exports.getTotalCheckoutItemsQuantity=m;exports.getCheckoutPenguinLockersMetaData=_;exports.getUniqueCheckoutPenguinDeliveryCodes=T;exports.isWoltDeliveryInProgress=p;exports.isWalletTopUpCheckoutItem=y;exports.isWalletTopUpCheckout=I;exports.getCheckoutWalletTopUpMetaData=P;exports.isGiftCardCheckout=M;exports.isGiftCardCheckoutItem=D;exports.getCheckoutGiftCardMetaData=G;exports.getCheckoutGuestGroupsMetaData=f;
|
package/checkout/index.mjs
CHANGED
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { default as
|
|
3
|
-
import { TranslationKey as
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { CheckoutPaymentErrorTranslationKey as
|
|
17
|
-
import { default as
|
|
18
|
-
import { default as
|
|
19
|
-
import { default as
|
|
20
|
-
import { default as
|
|
21
|
-
import { default as
|
|
22
|
-
import { default as
|
|
1
|
+
import { default as n } from "./getCheckoutItemModifications.mjs";
|
|
2
|
+
import { default as T } from "./getCheckoutProductName.mjs";
|
|
3
|
+
import { TranslationKey as I, default as P } from "./getCheckoutOrderStatusTexts.mjs";
|
|
4
|
+
import { default as G } from "./getCheckoutItemsMappedByTicketItemStatus.mjs";
|
|
5
|
+
import { default as W } from "./isCheckoutOrderSummary.mjs";
|
|
6
|
+
import { default as S } from "./buildCheckoutRequestItem.mjs";
|
|
7
|
+
import { default as q } from "./getCheckoutGrandTotalAmount.mjs";
|
|
8
|
+
import { default as v } from "./getCheckoutRequestItemFromCheckoutItem.mjs";
|
|
9
|
+
import { default as w } from "./isCheckoutItemsAreEqual.mjs";
|
|
10
|
+
import { default as K } from "./checkoutHasWallet.mjs";
|
|
11
|
+
import { default as b } from "./getWalletMetaFromCheckout.mjs";
|
|
12
|
+
import { default as H } from "./isPreOrderServiceTime.mjs";
|
|
13
|
+
import { default as N } from "./isPreOrderCheckout.mjs";
|
|
14
|
+
import { default as j } from "./isUpdatingCheckoutAllowed.mjs";
|
|
15
|
+
import { default as J } from "./isCheckoutAlreadyPaidStatus.mjs";
|
|
16
|
+
import { CheckoutPaymentErrorTranslationKey as X, default as Y } from "./getCheckoutPaymentErrorTranslationTexts.mjs";
|
|
17
|
+
import { default as _ } from "./isDeletingCheckoutAllowed.mjs";
|
|
18
|
+
import { default as tt } from "./getTotalCheckoutItemsQuantity.mjs";
|
|
19
|
+
import { default as ot } from "./getCheckoutPenguinLockersMetaData.mjs";
|
|
20
|
+
import { default as at } from "./getUniqueCheckoutPenguinDeliveryCodes.mjs";
|
|
21
|
+
import { default as mt } from "./isWoltDeliveryInProgress.mjs";
|
|
22
|
+
import { default as ft } from "./isWalletTopUpCheckoutItem.mjs";
|
|
23
23
|
import { default as lt } from "./isWalletTopUpCheckout.mjs";
|
|
24
|
-
import { default as
|
|
25
|
-
import { default as
|
|
26
|
-
import { default as
|
|
27
|
-
import { default as
|
|
28
|
-
import { default as
|
|
24
|
+
import { default as dt } from "./getCheckoutWalletTopUpMetaData.mjs";
|
|
25
|
+
import { default as Ct } from "./isGiftCardCheckout.mjs";
|
|
26
|
+
import { default as xt } from "./isGiftCardCheckoutItem.mjs";
|
|
27
|
+
import { default as nt } from "./getCheckoutGiftCardMetaData.mjs";
|
|
28
|
+
import { default as Tt } from "./getCheckoutGuestGroupsMetaData.mjs";
|
|
29
29
|
import "@ancon/wildcat-types";
|
|
30
30
|
import "../currency/getFormattedCurrency.mjs";
|
|
31
|
+
import "../currency/placeCurrencySymbol.mjs";
|
|
31
32
|
import "../currency/getFormattedCurrencyPostfix.mjs";
|
|
32
33
|
import "../order/getCheckOrderItemsMappedByTicketItemStatus.mjs";
|
|
33
34
|
import "../order/getCheckOrderMinimumStatusTicketItem.mjs";
|
|
@@ -42,34 +43,34 @@ import "../order/getMultiProductSubProductsTicketItems.mjs";
|
|
|
42
43
|
import "axios";
|
|
43
44
|
import "../error/isSerializedAPIError.mjs";
|
|
44
45
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
46
|
+
X as CheckoutPaymentErrorTranslationKey,
|
|
47
|
+
I as TranslationKey,
|
|
48
|
+
S as buildCheckoutRequestItem,
|
|
49
|
+
K as checkoutHasWallet,
|
|
50
|
+
nt as getCheckoutGiftCardMetaData,
|
|
51
|
+
q as getCheckoutGrandTotalAmount,
|
|
52
|
+
n as getCheckoutGroupedModifications,
|
|
53
|
+
Tt as getCheckoutGuestGroupsMetaData,
|
|
54
|
+
G as getCheckoutItemsMappedByTicketItemStatus,
|
|
55
|
+
P as getCheckoutOrderStatusTexts,
|
|
56
|
+
Y as getCheckoutPaymentErrorTranslationTexts,
|
|
57
|
+
ot as getCheckoutPenguinLockersMetaData,
|
|
58
|
+
T as getCheckoutProductName,
|
|
59
|
+
v as getCheckoutRequestItemFromCheckoutItem,
|
|
60
|
+
dt as getCheckoutWalletTopUpMetaData,
|
|
61
|
+
tt as getTotalCheckoutItemsQuantity,
|
|
62
|
+
at as getUniqueCheckoutPenguinDeliveryCodes,
|
|
63
|
+
b as getWalletMetaFromCheckout,
|
|
64
|
+
J as isCheckoutAlreadyPaidStatus,
|
|
65
|
+
w as isCheckoutItemsAreEqual,
|
|
66
|
+
W as isCheckoutOrderSummary,
|
|
67
|
+
_ as isDeletingCheckoutAllowed,
|
|
68
|
+
Ct as isGiftCardCheckout,
|
|
69
|
+
xt as isGiftCardCheckoutItem,
|
|
70
|
+
N as isPreOrderCheckout,
|
|
71
|
+
H as isPreOrderServiceTime,
|
|
72
|
+
j as isUpdatingCheckoutAllowed,
|
|
72
73
|
lt as isWalletTopUpCheckout,
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
ft as isWalletTopUpCheckoutItem,
|
|
75
|
+
mt as isWoltDeliveryInProgress
|
|
75
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const y=require("./placeCurrencySymbol.js");require("./getFormattedCurrencyPostfix.js");function N(d=0,s="SEK",e=!0){let l=0;const c=typeof e=="object"?{formatPostfix:(e==null?void 0:e.formatPostfix)??!0,trimTrailingZeros:(e==null?void 0:e.trimTrailingZeros)??!0,showAsManyDecimalsAsNeeded:(e==null?void 0:e.showAsManyDecimalsAsNeeded)??!1,maxAsManyDecimalsAsNeeded:(e==null?void 0:e.maxAsManyDecimalsAsNeeded)??8,onlyShowAsManyDecimalsAsNeededWhenZeroInt:(e==null?void 0:e.onlyShowAsManyDecimalsAsNeededWhenZeroInt)??!0,showCurrencyPostfix:(e==null?void 0:e.showCurrencyPostfix)??!0}:{formatPostfix:e,trimTrailingZeros:!0,showAsManyDecimalsAsNeeded:!1,maxAsManyDecimalsAsNeeded:8,onlyShowAsManyDecimalsAsNeededWhenZeroInt:!0,showCurrencyPostfix:!0};if(!d||Number.isNaN(Number(d)))l=0;else if(c.trimTrailingZeros&&Number.isInteger(Number(d)))l=d;else if(c.showAsManyDecimalsAsNeeded){l=Number(d).toFixed(c.maxAsManyDecimalsAsNeeded);const[A,u]=l.split("."),n=u!=null&&u.length>2?u.replace(/0+$/,""):u;(c.onlyShowAsManyDecimalsAsNeededWhenZeroInt?A==="0":!0)&&A!=null&&n!=null&&n.length>2?l=`${A}.${n}`:l=Number(d).toFixed(2)}else l=Number(d).toFixed(2),c.trimTrailingZeros&&l.endsWith(".00")&&(l=Number.parseInt(l,10).toString());return c.showCurrencyPostfix===!1?`${l}`:c.formatPostfix?y(l,s):`${l} ${s}`}module.exports=N;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import N from "./
|
|
2
|
-
|
|
1
|
+
import N from "./placeCurrencySymbol.mjs";
|
|
2
|
+
import "./getFormattedCurrencyPostfix.mjs";
|
|
3
|
+
function D(d = 0, y = "SEK", e = !0) {
|
|
3
4
|
let l = 0;
|
|
4
5
|
const c = typeof e == "object" ? {
|
|
5
6
|
formatPostfix: (e == null ? void 0 : e.formatPostfix) ?? !0,
|
|
@@ -26,10 +27,7 @@ function D(d = 0, s = "SEK", e = !0) {
|
|
|
26
27
|
(c.onlyShowAsManyDecimalsAsNeededWhenZeroInt ? u === "0" : !0) && u != null && n != null && n.length > 2 ? l = `${u}.${n}` : l = Number(d).toFixed(2);
|
|
27
28
|
} else
|
|
28
29
|
l = Number(d).toFixed(2), c.trimTrailingZeros && l.endsWith(".00") && (l = Number.parseInt(l, 10).toString());
|
|
29
|
-
|
|
30
|
-
return `${l}`;
|
|
31
|
-
const y = c.formatPostfix ? N(s) : s;
|
|
32
|
-
return `${l} ${y}`;
|
|
30
|
+
return c.showCurrencyPostfix === !1 ? `${l}` : c.formatPostfix ? N(l, y) : `${l} ${y}`;
|
|
33
31
|
}
|
|
34
32
|
export {
|
|
35
33
|
D as default
|
package/currency/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import getFormattedCurrency from './getFormattedCurrency';
|
|
2
2
|
import getFormattedCurrencyPostfix from './getFormattedCurrencyPostfix';
|
|
3
|
-
|
|
3
|
+
import placeCurrencySymbol from './placeCurrencySymbol';
|
|
4
|
+
export { getFormattedCurrency, getFormattedCurrencyPostfix, placeCurrencySymbol };
|
package/currency/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getFormattedCurrency.js"),r=require("./getFormattedCurrencyPostfix.js");exports.getFormattedCurrency=e;exports.getFormattedCurrencyPostfix=r;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./getFormattedCurrency.js"),r=require("./getFormattedCurrencyPostfix.js"),t=require("./placeCurrencySymbol.js");exports.getFormattedCurrency=e;exports.getFormattedCurrencyPostfix=r;exports.placeCurrencySymbol=t;
|
package/currency/index.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as t } from "./getFormattedCurrency.mjs";
|
|
2
2
|
import { default as a } from "./getFormattedCurrencyPostfix.mjs";
|
|
3
|
+
import { default as m } from "./placeCurrencySymbol.mjs";
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
a as getFormattedCurrencyPostfix
|
|
5
|
+
t as getFormattedCurrency,
|
|
6
|
+
a as getFormattedCurrencyPostfix,
|
|
7
|
+
m as placeCurrencySymbol
|
|
6
8
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Place the currency symbol around an already formatted amount according to
|
|
3
|
+
* the currency's convention (ie "£4.50" or "4.50 kr")
|
|
4
|
+
* @param {string|number} formattedAmount - Formatted amount (ie "4.50")
|
|
5
|
+
* @param {string} currency - Currency string (ie "SEK")
|
|
6
|
+
* @return {string} - Amount with the currency symbol placed
|
|
7
|
+
*/
|
|
8
|
+
export default function placeCurrencySymbol(formattedAmount: string | number, currency?: string | null): string;
|