addio-ecomm-sdk 1.3.74 → 1.3.76

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.
Files changed (107) hide show
  1. package/.vscode/settings.json +34 -34
  2. package/README.md +79 -79
  3. package/dist/index.d.ts +203 -202
  4. package/dist/index.js +1818 -1818
  5. package/dist/index.js.map +1 -1
  6. package/dist/lib/constants/components/CreditCardInput.d.ts +11 -11
  7. package/dist/lib/constants/components/CreditCardInput.js +79 -79
  8. package/dist/lib/constants/components/Snackbar.d.ts +11 -11
  9. package/dist/lib/constants/components/Snackbar.js +39 -39
  10. package/dist/lib/constants/contexts/CartContext/CartContextProvider.d.ts +7 -7
  11. package/dist/lib/constants/contexts/CartContext/CartContextProvider.js +980 -980
  12. package/dist/lib/constants/contexts/CartContext/index.d.ts +79 -79
  13. package/dist/lib/constants/contexts/CartContext/index.js +127 -127
  14. package/dist/lib/constants/contexts/DataContext/DataContextProvider.d.ts +15 -15
  15. package/dist/lib/constants/contexts/DataContext/DataContextProvider.js +304 -304
  16. package/dist/lib/constants/contexts/DataContext/index.d.ts +47 -47
  17. package/dist/lib/constants/contexts/DataContext/index.js +67 -67
  18. package/dist/lib/constants/contexts/LogContext/LogContextProvider.d.ts +6 -6
  19. package/dist/lib/constants/contexts/LogContext/LogContextProvider.js +103 -103
  20. package/dist/lib/constants/contexts/LogContext/index.d.ts +7 -7
  21. package/dist/lib/constants/contexts/LogContext/index.js +45 -45
  22. package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.d.ts +7 -7
  23. package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.js +76 -76
  24. package/dist/lib/constants/contexts/ModalContext/index.d.ts +14 -14
  25. package/dist/lib/constants/contexts/ModalContext/index.js +18 -18
  26. package/dist/lib/constants/contexts/SDKContext/SDKProvider.d.ts +8 -8
  27. package/dist/lib/constants/contexts/SDKContext/SDKProvider.js +79 -79
  28. package/dist/lib/constants/contexts/SDKContext/index.d.ts +4 -4
  29. package/dist/lib/constants/contexts/SDKContext/index.js +4 -4
  30. package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.d.ts +4 -4
  31. package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.js +6 -6
  32. package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.d.ts +12 -12
  33. package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.js +52 -52
  34. package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.d.ts +17 -17
  35. package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.js +21 -21
  36. package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.d.ts +7 -7
  37. package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.js +179 -179
  38. package/dist/lib/constants/contexts/StockNotifContext/index.d.ts +10 -10
  39. package/dist/lib/constants/contexts/StockNotifContext/index.js +10 -10
  40. package/dist/lib/constants/contexts/UserContext/UserContextProvider.d.ts +5 -5
  41. package/dist/lib/constants/contexts/UserContext/UserContextProvider.js +470 -470
  42. package/dist/lib/constants/contexts/UserContext/index.d.ts +54 -54
  43. package/dist/lib/constants/contexts/UserContext/index.js +82 -82
  44. package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.d.ts +6 -6
  45. package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.js +327 -327
  46. package/dist/lib/constants/contexts/WishlistContext/index.d.ts +12 -12
  47. package/dist/lib/constants/contexts/WishlistContext/index.js +12 -12
  48. package/dist/lib/constants/hooks/useCart.d.ts +2 -2
  49. package/dist/lib/constants/hooks/useCart.js +11 -11
  50. package/dist/lib/constants/hooks/useData.d.ts +2 -2
  51. package/dist/lib/constants/hooks/useData.js +11 -11
  52. package/dist/lib/constants/hooks/useLogs.d.ts +2 -2
  53. package/dist/lib/constants/hooks/useLogs.js +11 -11
  54. package/dist/lib/constants/hooks/useModal.d.ts +2 -2
  55. package/dist/lib/constants/hooks/useModal.js +11 -11
  56. package/dist/lib/constants/hooks/useSDK.d.ts +2 -2
  57. package/dist/lib/constants/hooks/useSDK.js +11 -11
  58. package/dist/lib/constants/hooks/useSnackbar.d.ts +2 -2
  59. package/dist/lib/constants/hooks/useSnackbar.js +11 -11
  60. package/dist/lib/constants/hooks/useStockNotif.d.ts +2 -2
  61. package/dist/lib/constants/hooks/useStockNotif.js +11 -11
  62. package/dist/lib/constants/hooks/useUser.d.ts +2 -2
  63. package/dist/lib/constants/hooks/useUser.js +11 -11
  64. package/dist/lib/constants/hooks/useWishlist.d.ts +2 -2
  65. package/dist/lib/constants/hooks/useWishlist.js +11 -11
  66. package/dist/lib/models/image/index.d.ts +6 -6
  67. package/dist/lib/models/image/index.js +15 -15
  68. package/dist/lib/models/stockNotification/index.d.ts +13 -13
  69. package/dist/lib/models/stockNotification/index.js +130 -130
  70. package/dist/lib/models/wishlist/index.d.ts +14 -14
  71. package/dist/lib/models/wishlist/index.js +155 -155
  72. package/dist/utils/StripeErrors.d.ts +24 -24
  73. package/dist/utils/StripeErrors.js +55 -55
  74. package/dist/utils/algolia.d.ts +3 -3
  75. package/dist/utils/algolia.js +81 -81
  76. package/dist/utils/analytics.d.ts +71 -71
  77. package/dist/utils/analytics.js +257 -257
  78. package/dist/utils/cart.d.ts +3 -3
  79. package/dist/utils/cart.js +66 -66
  80. package/dist/utils/contentful.d.ts +10 -10
  81. package/dist/utils/contentful.js +136 -136
  82. package/dist/utils/functions.d.ts +21 -21
  83. package/dist/utils/functions.js +200 -200
  84. package/dist/utils/getSDK.d.ts +4 -4
  85. package/dist/utils/getSDK.js +77 -77
  86. package/dist/utils/initStoreData.d.ts +3 -3
  87. package/dist/utils/initStoreData.js +62 -62
  88. package/dist/utils/interfaces/IClientCMSData.d.ts +132 -132
  89. package/dist/utils/interfaces/IClientCMSData.js +2 -2
  90. package/dist/utils/interfaces/IEndpointResult.d.ts +10 -10
  91. package/dist/utils/interfaces/IEndpointResult.js +2 -2
  92. package/dist/utils/interfaces/IFacebookUserProfile.d.ts +10 -10
  93. package/dist/utils/interfaces/IFacebookUserProfile.js +2 -2
  94. package/dist/utils/interfaces/IFilter.d.ts +23 -23
  95. package/dist/utils/interfaces/IFilter.js +2 -2
  96. package/dist/utils/interfaces/IGoogleUserProfile.d.ts +7 -7
  97. package/dist/utils/interfaces/IGoogleUserProfile.js +2 -2
  98. package/dist/utils/interfaces/ISDKConfig.d.ts +7 -7
  99. package/dist/utils/interfaces/ISDKConfig.js +2 -2
  100. package/dist/utils/interfaces/ISpaceData.d.ts +18 -18
  101. package/dist/utils/interfaces/ISpaceData.js +2 -2
  102. package/dist/utils/larivieremeunier.d.ts +3 -3
  103. package/dist/utils/larivieremeunier.js +156 -156
  104. package/dist/utils/technosupply.d.ts +3 -3
  105. package/dist/utils/technosupply.js +155 -155
  106. package/package.json +61 -61
  107. package/publish.sh +132 -132
@@ -1,201 +1,201 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.moneyFormat = exports.isEscompteSupplementaireItem = exports.getFullProdName = exports.getMinPrice = exports.calculateDistancesFromPoint = exports.toBase64 = exports.printTree = exports.numberWithSpaces = exports.getStringByLang = exports.translate = exports.string_to_slug = void 0;
15
- var lodash_1 = require("lodash");
16
- var g2_1 = require("addio-admin-sdk/dist/rules/GR/utils/g2");
17
- var currency_1 = require("addio-admin-sdk/dist/utils/currency");
18
- var addio_admin_sdk_1 = require("addio-admin-sdk");
19
- var categories_1 = require("addio-admin-sdk/dist/utils/categories");
20
- var string_to_slug = function (str) {
21
- str = str.replace(/^\s+|\s+$/g, '');
22
- str = str.toLowerCase();
23
- var from = 'åàáãäâèéëêìíïîòóöôùúüûñç·/_,:;';
24
- var to = 'aaaaaaeeeeiiiioooouuuunc------';
25
- for (var i = 0, l = from.length; i < l; i++) {
26
- str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
27
- }
28
- str = str
29
- .replace(/[^a-z0-9 -]/g, '')
30
- .replace(/\s+/g, '-')
31
- .replace(/-+/g, '-')
32
- .replace(/^-+/, '')
33
- .replace(/-+$/, '');
34
- return str;
35
- };
36
- exports.string_to_slug = string_to_slug;
37
- var translate = function (locale, translation) {
38
- if (locale === void 0) { locale = 'fr'; }
39
- try {
40
- if (typeof translation === 'string')
41
- return translation;
42
- var result = translation.find(function (str) { return str.lang === locale; });
43
- if (!!result) {
44
- return result.value;
45
- }
46
- return '';
47
- }
48
- catch (error) {
49
- console.log("error while translating:", translation);
50
- return '';
51
- }
52
- };
53
- exports.translate = translate;
54
- var getStringByLang = function (lang, locale) {
55
- return lang[locale || 'fr'];
56
- };
57
- exports.getStringByLang = getStringByLang;
58
- var numberWithSpaces = function (numStr) {
59
- if (typeof numStr === 'number')
60
- numStr = numStr.toString();
61
- var parts = numStr.split('.');
62
- parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, '\xa0');
63
- return parts.join('.');
64
- };
65
- exports.numberWithSpaces = numberWithSpaces;
66
- var getHierarchicalOrderBasedOnCategories = function (category, categories, order) {
67
- if (order === void 0) { order = 0; }
68
- if (!!!category.id)
69
- return order;
70
- var foundCategory = categories.find(function (c) { return c.id === category.parent; });
71
- if (!!!foundCategory)
72
- return order;
73
- return getHierarchicalOrderBasedOnCategories(foundCategory, categories, order + 1);
74
- };
75
- var printTree = function (categories, parent) {
76
- var categoryTree = (0, categories_1.buildTree)(categories, parent);
77
- return categoryTree;
78
- };
79
- exports.printTree = printTree;
80
- var _printTreeOld = function (categories, locale, level, parent) {
81
- if (locale === void 0) { locale = 'fr'; }
82
- if (level === void 0) { level = 0; }
83
- var _categories = categories.filter(function (category) { return getHierarchicalOrderBasedOnCategories(category, categories) === level; });
84
- if (_categories.length === 0)
85
- return;
86
- if (!!!parent) {
87
- return _categories.map(function (category) {
88
- try {
89
- return __assign(__assign({}, category), { name: category.name, children: _printTreeOld(categories, locale, level + 1, category.id) });
90
- }
91
- catch (err) {
92
- throw new Error("Category ".concat((0, exports.translate)(locale, category.name), ": ") + !!err ? err.toString() : '');
93
- }
94
- });
95
- }
96
- return _categories
97
- .filter(function (category) { return !!category.parent && category.parent === parent; })
98
- .map(function (c) {
99
- try {
100
- return __assign(__assign({}, c), { name: c.name, children: _printTreeOld(categories, locale, level + 1, c.id) });
101
- }
102
- catch (err) {
103
- throw new Error("Category ".concat(c.id, ": ") + !!err ? err.toString() : '');
104
- }
105
- });
106
- };
107
- var toBase64 = function (file) {
108
- return new Promise(function (resolve, reject) {
109
- var reader = new FileReader();
110
- reader.readAsDataURL(file);
111
- reader.onload = function () { return resolve(reader.result); };
112
- reader.onerror = function (error) { return reject(error); };
113
- });
114
- };
115
- exports.toBase64 = toBase64;
116
- var calculateDistancesFromPoint = function (position, markers) {
117
- if (!!!position)
118
- return [];
119
- var rad = function (x) {
120
- return (x * Math.PI) / 180;
121
- };
122
- var lat = position.lat;
123
- var lng = position.lng;
124
- var R = 6371;
125
- try {
126
- for (var i = 0; i < markers.length; i++) {
127
- if (markers[i] && !!markers[i].position) {
128
- var mlat = markers[i].position.lat;
129
- var mlng = markers[i].position.lng;
130
- var dLat = rad(mlat - lat);
131
- var dLong = rad(mlng - lng);
132
- var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
133
- Math.cos(rad(lat)) * Math.cos(rad(lat)) * Math.sin(dLong / 2) * Math.sin(dLong / 2);
134
- var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
135
- var d = R * c;
136
- markers[i].distance = d;
137
- }
138
- }
139
- return markers;
140
- }
141
- catch (e) {
142
- if (!!addio_admin_sdk_1.isTestEnv)
143
- console.log('error on fetching position for user: ', e.toString());
144
- return [];
145
- }
146
- };
147
- exports.calculateDistancesFromPoint = calculateDistancesFromPoint;
148
- var getMinPrice = function (cartItem, checkTierPricing) {
149
- if (checkTierPricing === void 0) { checkTierPricing = true; }
150
- var hasTierPricing = false;
151
- var amount = cartItem.regular_price.amount;
152
- var promo = cartItem.promo_price;
153
- var discount = cartItem.discount_price;
154
- var tierPricing = cartItem.tier_pricing;
155
- if (!!tierPricing && !!tierPricing.length && !!checkTierPricing) {
156
- hasTierPricing = true;
157
- var lowestTier = (0, lodash_1.minBy)(tierPricing, function (t) { return t.price.amount; });
158
- if (!!lowestTier) {
159
- if (lowestTier.price.amount < amount) {
160
- amount = lowestTier.price.amount;
161
- }
162
- }
163
- }
164
- if (!!promo) {
165
- if (!!discount && promo.amount < discount.amount && promo.amount !== 0)
166
- amount = promo.amount;
167
- if (promo.amount < amount && promo.amount !== 0)
168
- amount = promo.amount;
169
- }
170
- if (!!discount) {
171
- if (discount.amount < amount && discount.amount !== 0)
172
- amount = discount.amount;
173
- }
174
- return { amount: amount, hasTierPricing: hasTierPricing };
175
- };
176
- exports.getMinPrice = getMinPrice;
177
- var getFullProdName = function (item, locale) {
178
- var name = (0, exports.translate)(locale, item.name);
179
- var parentName = !!item.parent_name ? (0, exports.translate)(locale, item.parent_name) : '';
180
- var wordsIncludedInParentName = parentName.toLowerCase().trim().split(' ');
181
- var wordsIncludedInName = name.toLowerCase().trim().split(' ');
182
- var overlapInParentName = wordsIncludedInName.filter(function (word) { return !!parentName.toLowerCase().trim().includes(word); }).length ===
183
- wordsIncludedInName.length;
184
- var overlapInName = wordsIncludedInParentName.filter(function (word) { return !!name.toLowerCase().trim().includes(word); }).length ===
185
- wordsIncludedInParentName.length;
186
- if (!!parentName && !!!overlapInName && !!!overlapInParentName) {
187
- return "".concat(parentName, " - ").concat(name);
188
- }
189
- return name;
190
- };
191
- exports.getFullProdName = getFullProdName;
192
- var isEscompteSupplementaireItem = function (itemSku) {
193
- return (0, g2_1.isEscompteSuppItem)(itemSku);
194
- };
195
- exports.isEscompteSupplementaireItem = isEscompteSupplementaireItem;
196
- var moneyFormat = function (amount, currency, showZeros) {
197
- if (currency === void 0) { currency = 'CAD'; }
198
- return (0, currency_1.moneyFormat)(amount, currency, showZeros);
199
- };
200
- exports.moneyFormat = moneyFormat;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.moneyFormat = exports.isEscompteSupplementaireItem = exports.getFullProdName = exports.getMinPrice = exports.calculateDistancesFromPoint = exports.toBase64 = exports.printTree = exports.numberWithSpaces = exports.getStringByLang = exports.translate = exports.string_to_slug = void 0;
15
+ var lodash_1 = require("lodash");
16
+ var g2_1 = require("addio-admin-sdk/dist/rules/GR/utils/g2");
17
+ var currency_1 = require("addio-admin-sdk/dist/utils/currency");
18
+ var addio_admin_sdk_1 = require("addio-admin-sdk");
19
+ var categories_1 = require("addio-admin-sdk/dist/utils/categories");
20
+ var string_to_slug = function (str) {
21
+ str = str.replace(/^\s+|\s+$/g, '');
22
+ str = str.toLowerCase();
23
+ var from = 'åàáãäâèéëêìíïîòóöôùúüûñç·/_,:;';
24
+ var to = 'aaaaaaeeeeiiiioooouuuunc------';
25
+ for (var i = 0, l = from.length; i < l; i++) {
26
+ str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
27
+ }
28
+ str = str
29
+ .replace(/[^a-z0-9 -]/g, '')
30
+ .replace(/\s+/g, '-')
31
+ .replace(/-+/g, '-')
32
+ .replace(/^-+/, '')
33
+ .replace(/-+$/, '');
34
+ return str;
35
+ };
36
+ exports.string_to_slug = string_to_slug;
37
+ var translate = function (locale, translation) {
38
+ if (locale === void 0) { locale = 'fr'; }
39
+ try {
40
+ if (typeof translation === 'string')
41
+ return translation;
42
+ var result = translation.find(function (str) { return str.lang === locale; });
43
+ if (!!result) {
44
+ return result.value;
45
+ }
46
+ return '';
47
+ }
48
+ catch (error) {
49
+ console.log("error while translating:", translation);
50
+ return '';
51
+ }
52
+ };
53
+ exports.translate = translate;
54
+ var getStringByLang = function (lang, locale) {
55
+ return lang[locale || 'fr'];
56
+ };
57
+ exports.getStringByLang = getStringByLang;
58
+ var numberWithSpaces = function (numStr) {
59
+ if (typeof numStr === 'number')
60
+ numStr = numStr.toString();
61
+ var parts = numStr.split('.');
62
+ parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, '\xa0');
63
+ return parts.join('.');
64
+ };
65
+ exports.numberWithSpaces = numberWithSpaces;
66
+ var getHierarchicalOrderBasedOnCategories = function (category, categories, order) {
67
+ if (order === void 0) { order = 0; }
68
+ if (!!!category.id)
69
+ return order;
70
+ var foundCategory = categories.find(function (c) { return c.id === category.parent; });
71
+ if (!!!foundCategory)
72
+ return order;
73
+ return getHierarchicalOrderBasedOnCategories(foundCategory, categories, order + 1);
74
+ };
75
+ var printTree = function (categories, parent) {
76
+ var categoryTree = (0, categories_1.buildTree)(categories, parent);
77
+ return categoryTree;
78
+ };
79
+ exports.printTree = printTree;
80
+ var _printTreeOld = function (categories, locale, level, parent) {
81
+ if (locale === void 0) { locale = 'fr'; }
82
+ if (level === void 0) { level = 0; }
83
+ var _categories = categories.filter(function (category) { return getHierarchicalOrderBasedOnCategories(category, categories) === level; });
84
+ if (_categories.length === 0)
85
+ return;
86
+ if (!!!parent) {
87
+ return _categories.map(function (category) {
88
+ try {
89
+ return __assign(__assign({}, category), { name: category.name, children: _printTreeOld(categories, locale, level + 1, category.id) });
90
+ }
91
+ catch (err) {
92
+ throw new Error("Category ".concat((0, exports.translate)(locale, category.name), ": ") + !!err ? err.toString() : '');
93
+ }
94
+ });
95
+ }
96
+ return _categories
97
+ .filter(function (category) { return !!category.parent && category.parent === parent; })
98
+ .map(function (c) {
99
+ try {
100
+ return __assign(__assign({}, c), { name: c.name, children: _printTreeOld(categories, locale, level + 1, c.id) });
101
+ }
102
+ catch (err) {
103
+ throw new Error("Category ".concat(c.id, ": ") + !!err ? err.toString() : '');
104
+ }
105
+ });
106
+ };
107
+ var toBase64 = function (file) {
108
+ return new Promise(function (resolve, reject) {
109
+ var reader = new FileReader();
110
+ reader.readAsDataURL(file);
111
+ reader.onload = function () { return resolve(reader.result); };
112
+ reader.onerror = function (error) { return reject(error); };
113
+ });
114
+ };
115
+ exports.toBase64 = toBase64;
116
+ var calculateDistancesFromPoint = function (position, markers) {
117
+ if (!!!position)
118
+ return [];
119
+ var rad = function (x) {
120
+ return (x * Math.PI) / 180;
121
+ };
122
+ var lat = position.lat;
123
+ var lng = position.lng;
124
+ var R = 6371;
125
+ try {
126
+ for (var i = 0; i < markers.length; i++) {
127
+ if (markers[i] && !!markers[i].position) {
128
+ var mlat = markers[i].position.lat;
129
+ var mlng = markers[i].position.lng;
130
+ var dLat = rad(mlat - lat);
131
+ var dLong = rad(mlng - lng);
132
+ var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
133
+ Math.cos(rad(lat)) * Math.cos(rad(lat)) * Math.sin(dLong / 2) * Math.sin(dLong / 2);
134
+ var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
135
+ var d = R * c;
136
+ markers[i].distance = d;
137
+ }
138
+ }
139
+ return markers;
140
+ }
141
+ catch (e) {
142
+ if (!!addio_admin_sdk_1.isTestEnv)
143
+ console.log('error on fetching position for user: ', e.toString());
144
+ return [];
145
+ }
146
+ };
147
+ exports.calculateDistancesFromPoint = calculateDistancesFromPoint;
148
+ var getMinPrice = function (cartItem, checkTierPricing) {
149
+ if (checkTierPricing === void 0) { checkTierPricing = true; }
150
+ var hasTierPricing = false;
151
+ var amount = cartItem.regular_price.amount;
152
+ var promo = cartItem.promo_price;
153
+ var discount = cartItem.discount_price;
154
+ var tierPricing = cartItem.tier_pricing;
155
+ if (!!tierPricing && !!tierPricing.length && !!checkTierPricing) {
156
+ hasTierPricing = true;
157
+ var lowestTier = (0, lodash_1.minBy)(tierPricing, function (t) { return t.price.amount; });
158
+ if (!!lowestTier) {
159
+ if (lowestTier.price.amount < amount) {
160
+ amount = lowestTier.price.amount;
161
+ }
162
+ }
163
+ }
164
+ if (!!promo) {
165
+ if (!!discount && promo.amount < discount.amount && promo.amount !== 0)
166
+ amount = promo.amount;
167
+ if (promo.amount < amount && promo.amount !== 0)
168
+ amount = promo.amount;
169
+ }
170
+ if (!!discount) {
171
+ if (discount.amount < amount && discount.amount !== 0)
172
+ amount = discount.amount;
173
+ }
174
+ return { amount: amount, hasTierPricing: hasTierPricing };
175
+ };
176
+ exports.getMinPrice = getMinPrice;
177
+ var getFullProdName = function (item, locale) {
178
+ var name = (0, exports.translate)(locale, item.name);
179
+ var parentName = !!item.parent_name ? (0, exports.translate)(locale, item.parent_name) : '';
180
+ var wordsIncludedInParentName = parentName.toLowerCase().trim().split(' ');
181
+ var wordsIncludedInName = name.toLowerCase().trim().split(' ');
182
+ var overlapInParentName = wordsIncludedInName.filter(function (word) { return !!parentName.toLowerCase().trim().includes(word); }).length ===
183
+ wordsIncludedInName.length;
184
+ var overlapInName = wordsIncludedInParentName.filter(function (word) { return !!name.toLowerCase().trim().includes(word); }).length ===
185
+ wordsIncludedInParentName.length;
186
+ if (!!parentName && !!!overlapInName && !!!overlapInParentName) {
187
+ return "".concat(parentName, " - ").concat(name);
188
+ }
189
+ return name;
190
+ };
191
+ exports.getFullProdName = getFullProdName;
192
+ var isEscompteSupplementaireItem = function (itemSku) {
193
+ return (0, g2_1.isEscompteSuppItem)(itemSku);
194
+ };
195
+ exports.isEscompteSupplementaireItem = isEscompteSupplementaireItem;
196
+ var moneyFormat = function (amount, currency, showZeros) {
197
+ if (currency === void 0) { currency = 'CAD'; }
198
+ return (0, currency_1.moneyFormat)(amount, currency, showZeros);
199
+ };
200
+ exports.moneyFormat = moneyFormat;
201
201
  //# sourceMappingURL=functions.js.map
@@ -1,4 +1,4 @@
1
- import SDK from '..';
2
- import ISDKConfig from './interfaces/ISDKConfig';
3
- declare const getSDK: (sdk_config: ISDKConfig, isClientSide?: boolean) => Promise<SDK>;
4
- export default getSDK;
1
+ import SDK from '..';
2
+ import ISDKConfig from './interfaces/ISDKConfig';
3
+ declare const getSDK: (sdk_config: ISDKConfig, isClientSide?: boolean) => Promise<SDK>;
4
+ export default getSDK;
@@ -1,78 +1,78 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __importDefault = (this && this.__importDefault) || function (mod) {
50
- return (mod && mod.__esModule) ? mod : { "default": mod };
51
- };
52
- Object.defineProperty(exports, "__esModule", { value: true });
53
- var __1 = __importDefault(require(".."));
54
- var getSDK = function (sdk_config, isClientSide) {
55
- if (isClientSide === void 0) { isClientSide = true; }
56
- return __awaiter(void 0, void 0, void 0, function () {
57
- var userToken, localUserToken, sdk;
58
- return __generator(this, function (_a) {
59
- switch (_a.label) {
60
- case 0:
61
- userToken = sdk_config.userToken || '';
62
- if (isClientSide) {
63
- localUserToken = localStorage.getItem('userToken');
64
- if (localUserToken) {
65
- userToken = localUserToken;
66
- }
67
- }
68
- sdk = new __1.default();
69
- return [4, sdk.init(__assign(__assign({}, sdk_config), { userToken: userToken }))];
70
- case 1:
71
- _a.sent();
72
- return [2, sdk];
73
- }
74
- });
75
- });
76
- };
77
- exports.default = getSDK;
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ var __1 = __importDefault(require(".."));
54
+ var getSDK = function (sdk_config, isClientSide) {
55
+ if (isClientSide === void 0) { isClientSide = true; }
56
+ return __awaiter(void 0, void 0, void 0, function () {
57
+ var userToken, localUserToken, sdk;
58
+ return __generator(this, function (_a) {
59
+ switch (_a.label) {
60
+ case 0:
61
+ userToken = sdk_config.userToken || '';
62
+ if (isClientSide) {
63
+ localUserToken = localStorage.getItem('userToken');
64
+ if (localUserToken) {
65
+ userToken = localUserToken;
66
+ }
67
+ }
68
+ sdk = new __1.default();
69
+ return [4, sdk.init(__assign(__assign({}, sdk_config), { userToken: userToken }))];
70
+ case 1:
71
+ _a.sent();
72
+ return [2, sdk];
73
+ }
74
+ });
75
+ });
76
+ };
77
+ exports.default = getSDK;
78
78
  //# sourceMappingURL=getSDK.js.map
@@ -1,3 +1,3 @@
1
- import ISpaceData from './interfaces/ISpaceData';
2
- declare const initStoreData: (api: string, token: string) => Promise<ISpaceData>;
3
- export default initStoreData;
1
+ import ISpaceData from './interfaces/ISpaceData';
2
+ declare const initStoreData: (api: string, token: string) => Promise<ISpaceData>;
3
+ export default initStoreData;