@salesgenterp/ui-components 0.4.557 → 0.4.559

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/dist/index.js CHANGED
@@ -101,164 +101,9 @@ function _taggedTemplateLiteralLoose(e, t) {
101
101
  }
102
102
 
103
103
  // A type of promise-like that resolves synchronously and supports only one observer
104
- const _Pact = /*#__PURE__*/(function() {
105
- function _Pact() {}
106
- _Pact.prototype.then = function(onFulfilled, onRejected) {
107
- const result = new _Pact();
108
- const state = this.s;
109
- if (state) {
110
- const callback = state & 1 ? onFulfilled : onRejected;
111
- if (callback) {
112
- try {
113
- _settle(result, 1, callback(this.v));
114
- } catch (e) {
115
- _settle(result, 2, e);
116
- }
117
- return result;
118
- } else {
119
- return this;
120
- }
121
- }
122
- this.o = function(_this) {
123
- try {
124
- const value = _this.v;
125
- if (_this.s & 1) {
126
- _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
127
- } else if (onRejected) {
128
- _settle(result, 1, onRejected(value));
129
- } else {
130
- _settle(result, 2, value);
131
- }
132
- } catch (e) {
133
- _settle(result, 2, e);
134
- }
135
- };
136
- return result;
137
- };
138
- return _Pact;
139
- })();
140
-
141
- // Settles a pact synchronously
142
- function _settle(pact, state, value) {
143
- if (!pact.s) {
144
- if (value instanceof _Pact) {
145
- if (value.s) {
146
- if (state & 1) {
147
- state = value.s;
148
- }
149
- value = value.v;
150
- } else {
151
- value.o = _settle.bind(null, pact, state);
152
- return;
153
- }
154
- }
155
- if (value && value.then) {
156
- value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
157
- return;
158
- }
159
- pact.s = state;
160
- pact.v = value;
161
- const observer = pact.o;
162
- if (observer) {
163
- observer(pact);
164
- }
165
- }
166
- }
167
-
168
- function _isSettledPact(thenable) {
169
- return thenable instanceof _Pact && thenable.s & 1;
170
- }
171
-
172
- // Asynchronously iterate through an object that has a length property, passing the index as the first argument to the callback (even as the length property changes)
173
- function _forTo(array, body, check) {
174
- var i = -1, pact, reject;
175
- function _cycle(result) {
176
- try {
177
- while (++i < array.length && (!check || !check())) {
178
- result = body(i);
179
- if (result && result.then) {
180
- if (_isSettledPact(result)) {
181
- result = result.v;
182
- } else {
183
- result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
184
- return;
185
- }
186
- }
187
- }
188
- if (pact) {
189
- _settle(pact, 1, result);
190
- } else {
191
- pact = result;
192
- }
193
- } catch (e) {
194
- _settle(pact || (pact = new _Pact()), 2, e);
195
- }
196
- }
197
- _cycle();
198
- return pact;
199
- }
200
104
 
201
105
  const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
202
106
 
203
- // Asynchronously iterate through an object's values
204
- // Uses for...of if the runtime supports it, otherwise iterates until length on a copy
205
- function _forOf(target, body, check) {
206
- if (typeof target[_iteratorSymbol] === "function") {
207
- var iterator = target[_iteratorSymbol](), step, pact, reject;
208
- function _cycle(result) {
209
- try {
210
- while (!(step = iterator.next()).done && (!check || !check())) {
211
- result = body(step.value);
212
- if (result && result.then) {
213
- if (_isSettledPact(result)) {
214
- result = result.v;
215
- } else {
216
- result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
217
- return;
218
- }
219
- }
220
- }
221
- if (pact) {
222
- _settle(pact, 1, result);
223
- } else {
224
- pact = result;
225
- }
226
- } catch (e) {
227
- _settle(pact || (pact = new _Pact()), 2, e);
228
- }
229
- }
230
- _cycle();
231
- if (iterator.return) {
232
- var _fixup = function(value) {
233
- try {
234
- if (!step.done) {
235
- iterator.return();
236
- }
237
- } catch(e) {
238
- }
239
- return value;
240
- };
241
- if (pact && pact.then) {
242
- return pact.then(_fixup, function(e) {
243
- throw _fixup(e);
244
- });
245
- }
246
- _fixup();
247
- }
248
- return pact;
249
- }
250
- // No support for Symbol.iterator
251
- if (!("length" in target)) {
252
- throw new TypeError("Object is not iterable");
253
- }
254
- // Handle live collections properly
255
- var values = [];
256
- for (var i = 0; i < target.length; i++) {
257
- values.push(target[i]);
258
- }
259
- return _forTo(values, function(i) { return body(values[i]); }, check);
260
- }
261
-
262
107
  const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
263
108
 
264
109
  // Asynchronously call a function and send errors to recovery continuation
@@ -313,7 +158,8 @@ var DATE_FORMATS = {
313
158
  var DEFAULT_PAYMENT_PROVIDER = {
314
159
  BRAIN_TREE: 'braintree',
315
160
  CUSTOM_CREDIT_CARD: 'braintree',
316
- AUTHORISE_DOT_NET: 'authorise-dot-net'
161
+ AUTHORISE_DOT_NET: 'authorise-dot-net',
162
+ NMI: 'nmi'
317
163
  };
318
164
  var CARD_METHODS = {
319
165
  CREDIT_CARD: 2,
@@ -1032,38 +878,67 @@ var getPaymentMethods = function getPaymentMethods(_ref2) {
1032
878
  return Promise.reject(e);
1033
879
  }
1034
880
  };
1035
- var getStoreFeatureDetails = function getStoreFeatureDetails(_ref3) {
1036
- var apiEndPoint = _ref3.apiEndPoint,
1037
- token = _ref3.token;
881
+ var getAuthorizeDotNetCreditCards = function getAuthorizeDotNetCreditCards(_ref4) {
882
+ var apiEndPoint = _ref4.apiEndPoint,
883
+ token = _ref4.token,
884
+ customerId = _ref4.customerId;
1038
885
  try {
1039
886
  return Promise.resolve(API({
1040
887
  apiEndPoint: apiEndPoint,
1041
888
  token: token,
1042
- url: "/store/feature"
889
+ url: "/ecommerce/authoriseDotNet/customerProfile?customerId=" + customerId,
890
+ hideErrorMessage: true
1043
891
  }));
1044
892
  } catch (e) {
1045
893
  return Promise.reject(e);
1046
894
  }
1047
895
  };
1048
- var getAuthorizeDotNetCreditCards = function getAuthorizeDotNetCreditCards(_ref4) {
1049
- var apiEndPoint = _ref4.apiEndPoint,
1050
- token = _ref4.token,
1051
- customerId = _ref4.customerId;
896
+ var getNmiCreditCards = function getNmiCreditCards(_ref5) {
897
+ var apiEndPoint = _ref5.apiEndPoint,
898
+ token = _ref5.token,
899
+ customerId = _ref5.customerId;
1052
900
  try {
1053
901
  return Promise.resolve(API({
1054
902
  apiEndPoint: apiEndPoint,
1055
903
  token: token,
1056
- url: "/ecommerce/authoriseDotNet/customerProfile?customerId=" + customerId,
904
+ url: "/nmi/customers/" + customerId + "/cards",
1057
905
  hideErrorMessage: true
1058
906
  }));
1059
907
  } catch (e) {
1060
908
  return Promise.reject(e);
1061
909
  }
1062
910
  };
1063
- var addAuthoriseDotNetCard = function addAuthoriseDotNetCard(_ref5) {
1064
- var apiEndPoint = _ref5.apiEndPoint,
1065
- token = _ref5.token,
1066
- body = _ref5.body;
911
+ var normalizeSavedCreditCards = function normalizeSavedCreditCards(data) {
912
+ var _data$profile, _cards$;
913
+ if (data !== null && data !== void 0 && (_data$profile = data.profile) !== null && _data$profile !== void 0 && _data$profile.paymentProfiles) return data;
914
+ var cards = Array.isArray(data) ? data : [];
915
+ return {
916
+ profile: {
917
+ customerProfileId: ((_cards$ = cards[0]) === null || _cards$ === void 0 ? void 0 : _cards$.customerProfileId) || null,
918
+ paymentProfiles: cards === null || cards === void 0 ? void 0 : cards.map(function (card) {
919
+ var _card$cardName, _card$cardName$split, _card$cardName$split$, _card$cardName2, _card$cardName2$split, _card$cardName2$split2, _card$cardName2$split3, _card$cardName2$split4, _card$cardName2$split5;
920
+ return {
921
+ customerPaymentProfileId: card === null || card === void 0 ? void 0 : card.customerPaymentProfileId,
922
+ payment: {
923
+ creditCard: {
924
+ cardType: (card === null || card === void 0 ? void 0 : card.cardName) || 'Card',
925
+ cardNumber: card !== null && card !== void 0 && card.last4 ? "XXXX" + (card === null || card === void 0 ? void 0 : card.last4) : '',
926
+ expirationDate: card !== null && card !== void 0 && card.expirationMonth && card !== null && card !== void 0 && card.expirationYear ? (card === null || card === void 0 ? void 0 : card.expirationMonth) + "/" + (card === null || card === void 0 ? void 0 : card.expirationYear) : '----'
927
+ }
928
+ },
929
+ billTo: {
930
+ firstName: (card === null || card === void 0 ? void 0 : (_card$cardName = card.cardName) === null || _card$cardName === void 0 ? void 0 : (_card$cardName$split = _card$cardName.split) === null || _card$cardName$split === void 0 ? void 0 : (_card$cardName$split$ = _card$cardName$split.call(_card$cardName, ' ')) === null || _card$cardName$split$ === void 0 ? void 0 : _card$cardName$split$[0]) || '',
931
+ lastName: (card === null || card === void 0 ? void 0 : (_card$cardName2 = card.cardName) === null || _card$cardName2 === void 0 ? void 0 : (_card$cardName2$split = _card$cardName2.split) === null || _card$cardName2$split === void 0 ? void 0 : (_card$cardName2$split2 = _card$cardName2$split.call(_card$cardName2, ' ')) === null || _card$cardName2$split2 === void 0 ? void 0 : (_card$cardName2$split3 = _card$cardName2$split2.slice) === null || _card$cardName2$split3 === void 0 ? void 0 : (_card$cardName2$split4 = _card$cardName2$split3.call(_card$cardName2$split2, 1)) === null || _card$cardName2$split4 === void 0 ? void 0 : (_card$cardName2$split5 = _card$cardName2$split4.join) === null || _card$cardName2$split5 === void 0 ? void 0 : _card$cardName2$split5.call(_card$cardName2$split4, ' ')) || ''
932
+ }
933
+ };
934
+ })
935
+ }
936
+ };
937
+ };
938
+ var addAuthoriseDotNetCard = function addAuthoriseDotNetCard(_ref6) {
939
+ var apiEndPoint = _ref6.apiEndPoint,
940
+ token = _ref6.token,
941
+ body = _ref6.body;
1067
942
  try {
1068
943
  return Promise.resolve(API({
1069
944
  apiEndPoint: apiEndPoint,
@@ -1077,9 +952,27 @@ var addAuthoriseDotNetCard = function addAuthoriseDotNetCard(_ref5) {
1077
952
  return Promise.reject(e);
1078
953
  }
1079
954
  };
1080
- var getCartDiscountList = function getCartDiscountList(_ref6) {
1081
- var apiEndPoint = _ref6.apiEndPoint,
1082
- token = _ref6.token;
955
+ var addNmiCard = function addNmiCard(_ref7) {
956
+ var apiEndPoint = _ref7.apiEndPoint,
957
+ token = _ref7.token,
958
+ body = _ref7.body,
959
+ customerId = _ref7.customerId;
960
+ try {
961
+ return Promise.resolve(API({
962
+ apiEndPoint: apiEndPoint,
963
+ token: token,
964
+ url: "/nmi/customers/" + customerId + "/cards",
965
+ method: 'post',
966
+ body: body,
967
+ errorMessage: 'Error in adding card.'
968
+ }));
969
+ } catch (e) {
970
+ return Promise.reject(e);
971
+ }
972
+ };
973
+ var getCartDiscountList = function getCartDiscountList(_ref8) {
974
+ var apiEndPoint = _ref8.apiEndPoint,
975
+ token = _ref8.token;
1083
976
  try {
1084
977
  var storeId = erCookieStorage.getItem('storeId') || 2;
1085
978
  return Promise.resolve(API({
@@ -1092,10 +985,10 @@ var getCartDiscountList = function getCartDiscountList(_ref6) {
1092
985
  return Promise.reject(e);
1093
986
  }
1094
987
  };
1095
- var autoApplyCoupon = function autoApplyCoupon(_ref7) {
1096
- var apiEndPoint = _ref7.apiEndPoint,
1097
- token = _ref7.token,
1098
- subTotal = _ref7.subTotal;
988
+ var autoApplyCoupon = function autoApplyCoupon(_ref9) {
989
+ var apiEndPoint = _ref9.apiEndPoint,
990
+ token = _ref9.token,
991
+ subTotal = _ref9.subTotal;
1099
992
  try {
1100
993
  var storeId = erCookieStorage.getItem('storeId') || 2;
1101
994
  return Promise.resolve(API({
@@ -1112,10 +1005,10 @@ var autoApplyCoupon = function autoApplyCoupon(_ref7) {
1112
1005
  return Promise.reject(e);
1113
1006
  }
1114
1007
  };
1115
- var addCartDiscount = function addCartDiscount(_ref9) {
1116
- var apiEndPoint = _ref9.apiEndPoint,
1117
- token = _ref9.token,
1118
- body = _ref9.body;
1008
+ var addCartDiscount = function addCartDiscount(_ref11) {
1009
+ var apiEndPoint = _ref11.apiEndPoint,
1010
+ token = _ref11.token,
1011
+ body = _ref11.body;
1119
1012
  try {
1120
1013
  var storeId = erCookieStorage.getItem('storeId') || 2;
1121
1014
  return Promise.resolve(API({
@@ -1131,10 +1024,10 @@ var addCartDiscount = function addCartDiscount(_ref9) {
1131
1024
  return Promise.reject(e);
1132
1025
  }
1133
1026
  };
1134
- var deleteCartDiscount = function deleteCartDiscount(_ref10) {
1135
- var apiEndPoint = _ref10.apiEndPoint,
1136
- token = _ref10.token,
1137
- discountId = _ref10.discountId;
1027
+ var deleteCartDiscount = function deleteCartDiscount(_ref12) {
1028
+ var apiEndPoint = _ref12.apiEndPoint,
1029
+ token = _ref12.token,
1030
+ discountId = _ref12.discountId;
1138
1031
  try {
1139
1032
  var storeId = erCookieStorage.getItem('storeId') || 2;
1140
1033
  return Promise.resolve(API({
@@ -1149,10 +1042,10 @@ var deleteCartDiscount = function deleteCartDiscount(_ref10) {
1149
1042
  return Promise.reject(e);
1150
1043
  }
1151
1044
  };
1152
- var addSalesOrder = function addSalesOrder(_ref12) {
1153
- var apiEndPoint = _ref12.apiEndPoint,
1154
- token = _ref12.token,
1155
- orderDetails = _ref12.orderDetails;
1045
+ var addSalesOrder = function addSalesOrder(_ref14) {
1046
+ var apiEndPoint = _ref14.apiEndPoint,
1047
+ token = _ref14.token,
1048
+ orderDetails = _ref14.orderDetails;
1156
1049
  try {
1157
1050
  var storeId = erCookieStorage.getItem('storeId') || 2;
1158
1051
  return Promise.resolve(API({
@@ -1167,10 +1060,10 @@ var addSalesOrder = function addSalesOrder(_ref12) {
1167
1060
  return Promise.reject(e);
1168
1061
  }
1169
1062
  };
1170
- var addQuotation = function addQuotation(_ref13) {
1171
- var apiEndPoint = _ref13.apiEndPoint,
1172
- token = _ref13.token,
1173
- orderDetails = _ref13.orderDetails;
1063
+ var addQuotation = function addQuotation(_ref15) {
1064
+ var apiEndPoint = _ref15.apiEndPoint,
1065
+ token = _ref15.token,
1066
+ orderDetails = _ref15.orderDetails;
1174
1067
  try {
1175
1068
  var storeId = erCookieStorage.getItem('storeId') || 2;
1176
1069
  return Promise.resolve(API({
@@ -1185,9 +1078,9 @@ var addQuotation = function addQuotation(_ref13) {
1185
1078
  return Promise.reject(e);
1186
1079
  }
1187
1080
  };
1188
- var getCustomer = function getCustomer(_ref14) {
1189
- var apiEndPoint = _ref14.apiEndPoint,
1190
- token = _ref14.token;
1081
+ var getCustomer = function getCustomer(_ref16) {
1082
+ var apiEndPoint = _ref16.apiEndPoint,
1083
+ token = _ref16.token;
1191
1084
  try {
1192
1085
  return Promise.resolve(API({
1193
1086
  apiEndPoint: apiEndPoint,
@@ -1199,10 +1092,10 @@ var getCustomer = function getCustomer(_ref14) {
1199
1092
  return Promise.reject(e);
1200
1093
  }
1201
1094
  };
1202
- var getDeliveryOption = function getDeliveryOption(_ref15) {
1203
- var apiEndPoint = _ref15.apiEndPoint,
1204
- token = _ref15.token,
1205
- queryParams = _ref15.queryParams;
1095
+ var getDeliveryOption = function getDeliveryOption(_ref17) {
1096
+ var apiEndPoint = _ref17.apiEndPoint,
1097
+ token = _ref17.token,
1098
+ queryParams = _ref17.queryParams;
1206
1099
  try {
1207
1100
  return Promise.resolve(API({
1208
1101
  apiEndPoint: apiEndPoint,
@@ -1214,10 +1107,10 @@ var getDeliveryOption = function getDeliveryOption(_ref15) {
1214
1107
  return Promise.reject(e);
1215
1108
  }
1216
1109
  };
1217
- var getShipStationDeliveryOption = function getShipStationDeliveryOption(_ref16) {
1218
- var apiEndPoint = _ref16.apiEndPoint,
1219
- token = _ref16.token,
1220
- queryParams = _ref16.queryParams;
1110
+ var getShipStationDeliveryOption = function getShipStationDeliveryOption(_ref18) {
1111
+ var apiEndPoint = _ref18.apiEndPoint,
1112
+ token = _ref18.token,
1113
+ queryParams = _ref18.queryParams;
1221
1114
  try {
1222
1115
  return Promise.resolve(API({
1223
1116
  apiEndPoint: apiEndPoint,
@@ -1229,10 +1122,10 @@ var getShipStationDeliveryOption = function getShipStationDeliveryOption(_ref16)
1229
1122
  return Promise.reject(e);
1230
1123
  }
1231
1124
  };
1232
- var getTaxData = function getTaxData(_ref17) {
1233
- var apiEndPoint = _ref17.apiEndPoint,
1234
- token = _ref17.token,
1235
- shippingAddressId = _ref17.shippingAddressId;
1125
+ var getTaxData = function getTaxData(_ref19) {
1126
+ var apiEndPoint = _ref19.apiEndPoint,
1127
+ token = _ref19.token,
1128
+ shippingAddressId = _ref19.shippingAddressId;
1236
1129
  try {
1237
1130
  var storeId = erCookieStorage.getItem('storeId') || 2;
1238
1131
  return Promise.resolve(API({
@@ -1248,11 +1141,11 @@ var getTaxData = function getTaxData(_ref17) {
1248
1141
  return Promise.reject(e);
1249
1142
  }
1250
1143
  };
1251
- var createStoreAddress = function createStoreAddress(_ref18) {
1252
- var apiEndPoint = _ref18.apiEndPoint,
1253
- token = _ref18.token,
1254
- data = _ref18.data,
1255
- customerId = _ref18.customerId;
1144
+ var createStoreAddress = function createStoreAddress(_ref20) {
1145
+ var apiEndPoint = _ref20.apiEndPoint,
1146
+ token = _ref20.token,
1147
+ data = _ref20.data,
1148
+ customerId = _ref20.customerId;
1256
1149
  try {
1257
1150
  return Promise.resolve(API({
1258
1151
  apiEndPoint: apiEndPoint,
@@ -2325,6 +2218,7 @@ var getCountry = function getCountry(_ref2) {
2325
2218
  var AddAuthorizeDotNetCard = function AddAuthorizeDotNetCard(_ref) {
2326
2219
  var apiEndPoint = _ref.apiEndPoint,
2327
2220
  token = _ref.token,
2221
+ paymentProvider = _ref.paymentProvider,
2328
2222
  visible = _ref.visible,
2329
2223
  onCancel = _ref.onCancel,
2330
2224
  styles = _ref.styles,
@@ -2398,7 +2292,7 @@ var AddAuthorizeDotNetCard = function AddAuthorizeDotNetCard(_ref) {
2398
2292
  };
2399
2293
  var onSubmit = function onSubmit(formData) {
2400
2294
  try {
2401
- var _temp3 = function _temp3() {
2295
+ var _temp6 = function _temp6() {
2402
2296
  setSubmitLoading(false);
2403
2297
  };
2404
2298
  setSubmitLoading(true);
@@ -2408,17 +2302,35 @@ var AddAuthorizeDotNetCard = function AddAuthorizeDotNetCard(_ref) {
2408
2302
  customerId: customerId
2409
2303
  })
2410
2304
  };
2411
- var _temp2 = _catch(function () {
2412
- return Promise.resolve(addAuthoriseDotNetCard({
2413
- apiEndPoint: apiEndPoint,
2414
- token: token,
2415
- body: body
2416
- })).then(function () {
2305
+ var _temp5 = _catch(function () {
2306
+ function _temp4() {
2417
2307
  setListUpdate && setListUpdate(getRandomString());
2418
2308
  onCancel && onCancel();
2419
- });
2309
+ }
2310
+ var _temp3 = function () {
2311
+ if (paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet) {
2312
+ return Promise.resolve(addAuthoriseDotNetCard({
2313
+ apiEndPoint: apiEndPoint,
2314
+ token: token,
2315
+ body: body
2316
+ })).then(function () {});
2317
+ } else {
2318
+ var _temp7 = function () {
2319
+ if (paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.nmi) {
2320
+ return Promise.resolve(addNmiCard({
2321
+ apiEndPoint: apiEndPoint,
2322
+ token: token,
2323
+ body: body === null || body === void 0 ? void 0 : body.customerOrderCard,
2324
+ customerId: customerId
2325
+ })).then(function () {});
2326
+ }
2327
+ }();
2328
+ if (_temp7 && _temp7.then) return _temp7.then(function () {});
2329
+ }
2330
+ }();
2331
+ return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
2420
2332
  }, function () {});
2421
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
2333
+ return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
2422
2334
  } catch (e) {
2423
2335
  return Promise.reject(e);
2424
2336
  }
@@ -2580,7 +2492,7 @@ var AddAuthorizeDotNetCard = function AddAuthorizeDotNetCard(_ref) {
2580
2492
 
2581
2493
  var _templateObject$9;
2582
2494
  var PaymentModal = function PaymentModal(_ref) {
2583
- var _customerCreditCards$, _customerCreditCards$2, _orderData$orderDto5, _orderData$orderDto6, _orderData$orderDto7, _orderData$orderDto8, _orderData$customerDt, _orderData$customerDt2, _orderData$orderDto9, _orderData$orderDto10, _authorizeDotNetCardD, _authorizeDotNetCardD2, _authorizeDotNetCardD3, _authorizeDotNetCardD4, _authorizeDotNetCardD5, _authorizeDotNetCardD6, _authorizeDotNetCardD7, _authorizeDotNetCardD8, _customerCreditCards$4, _customerCreditCards$5;
2495
+ var _customerCreditCards$, _customerCreditCards$2, _orderData$orderDto6, _orderData$orderDto7, _orderData$orderDto8, _orderData$orderDto9, _orderData$customerDt, _orderData$customerDt2, _orderData$orderDto10, _orderData$orderDto11, _authorizeDotNetCardD, _authorizeDotNetCardD2, _authorizeDotNetCardD3, _authorizeDotNetCardD4, _authorizeDotNetCardD5, _authorizeDotNetCardD6, _authorizeDotNetCardD7, _authorizeDotNetCardD8, _customerCreditCards$4, _customerCreditCards$5;
2584
2496
  var apiEndPoint = _ref.apiEndPoint,
2585
2497
  token = _ref.token,
2586
2498
  visible = _ref.visible,
@@ -2588,7 +2500,8 @@ var PaymentModal = function PaymentModal(_ref) {
2588
2500
  styles = _ref.styles,
2589
2501
  orderId = _ref.orderId,
2590
2502
  storeIdList = _ref.storeIdList,
2591
- setTriggerTableData = _ref.setTriggerTableData;
2503
+ setTriggerTableData = _ref.setTriggerTableData,
2504
+ paymentProvider = _ref.paymentProvider;
2592
2505
  var _useState = React.useState(),
2593
2506
  orderData = _useState[0],
2594
2507
  setOrderData = _useState[1];
@@ -2605,11 +2518,8 @@ var PaymentModal = function PaymentModal(_ref) {
2605
2518
  submitLoading = _useState5[0],
2606
2519
  setSubmitLoading = _useState5[1];
2607
2520
  var _useState6 = React.useState(),
2608
- defaultPaymentProvider = _useState6[0],
2609
- setDefaultPaymentProvider = _useState6[1];
2610
- var _useState7 = React.useState(),
2611
- listUpdate = _useState7[0],
2612
- setListUpdate = _useState7[1];
2521
+ listUpdate = _useState6[0],
2522
+ setListUpdate = _useState6[1];
2613
2523
  var _useForm = reactHookForm.useForm({
2614
2524
  defaultValues: {
2615
2525
  insertedTimestamp: getLocalTime({
@@ -2622,17 +2532,18 @@ var PaymentModal = function PaymentModal(_ref) {
2622
2532
  control = _useForm.control,
2623
2533
  setValue = _useForm.setValue,
2624
2534
  watch = _useForm.watch;
2625
- var _useState8 = React.useState([]),
2626
- setPaymentMethods = _useState8[1];
2627
- var _useState9 = React.useState(),
2628
- customerCreditCards = _useState9[0],
2629
- setCustomerCreditCards = _useState9[1];
2535
+ var _useState7 = React.useState([]),
2536
+ setPaymentMethods = _useState7[1];
2537
+ var _useState8 = React.useState(),
2538
+ customerCreditCards = _useState8[0],
2539
+ setCustomerCreditCards = _useState8[1];
2630
2540
  var paymentModeId = watch('paymentModeId');
2631
2541
  var authorizeDotNetCard = watch('authorizeDotNetCard');
2632
2542
  var authorizeDotNetCardData = customerCreditCards === null || customerCreditCards === void 0 ? void 0 : (_customerCreditCards$ = customerCreditCards.profile) === null || _customerCreditCards$ === void 0 ? void 0 : (_customerCreditCards$2 = _customerCreditCards$.paymentProfiles) === null || _customerCreditCards$2 === void 0 ? void 0 : _customerCreditCards$2.find(function (data) {
2633
2543
  return (data === null || data === void 0 ? void 0 : data.customerPaymentProfileId) === authorizeDotNetCard;
2634
2544
  });
2635
2545
  var storeId = erCookieStorage.getItem('storeId') || 2;
2546
+ var hasSavedCardProvider = (paymentProvider === null || paymentProvider === void 0 ? void 0 : paymentProvider.authoriseDotNet) || (paymentProvider === null || paymentProvider === void 0 ? void 0 : paymentProvider.nmi);
2636
2547
  React.useEffect(function () {
2637
2548
  if (apiEndPoint) {
2638
2549
  (function () {
@@ -2655,12 +2566,6 @@ var PaymentModal = function PaymentModal(_ref) {
2655
2566
  token: token
2656
2567
  })).then(function (data) {
2657
2568
  setPaymentMethods(data);
2658
- return Promise.resolve(getStoreFeatureDetails({
2659
- apiEndPoint: apiEndPoint,
2660
- token: token
2661
- })).then(function (storeDetails) {
2662
- setDefaultPaymentProvider(storeDetails === null || storeDetails === void 0 ? void 0 : storeDetails.defaultPaymentProvider);
2663
- });
2664
2569
  });
2665
2570
  });
2666
2571
  }, function () {});
@@ -2673,19 +2578,23 @@ var PaymentModal = function PaymentModal(_ref) {
2673
2578
  }, [orderId]);
2674
2579
  React.useEffect(function () {
2675
2580
  var _orderData$orderDto;
2676
- if (defaultPaymentProvider === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET && orderData !== null && orderData !== void 0 && (_orderData$orderDto = orderData.orderDto) !== null && _orderData$orderDto !== void 0 && _orderData$orderDto.customerId) {
2581
+ if (hasSavedCardProvider && orderData !== null && orderData !== void 0 && (_orderData$orderDto = orderData.orderDto) !== null && _orderData$orderDto !== void 0 && _orderData$orderDto.customerId) {
2677
2582
  if (lodash.includes(lodash.values(CARD_METHODS), paymentModeId)) {
2678
2583
  (function () {
2679
2584
  try {
2680
2585
  setCardLoading(API_STATUSES.LOADING);
2681
2586
  var _temp3 = _catch(function () {
2682
- var _orderData$orderDto2;
2683
- return Promise.resolve(getAuthorizeDotNetCreditCards({
2587
+ var _orderData$orderDto2, _orderData$orderDto3;
2588
+ return Promise.resolve(paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet ? getAuthorizeDotNetCreditCards({
2684
2589
  apiEndPoint: apiEndPoint,
2685
2590
  token: token,
2686
2591
  customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto2 = orderData.orderDto) === null || _orderData$orderDto2 === void 0 ? void 0 : _orderData$orderDto2.customerId
2592
+ }) : getNmiCreditCards({
2593
+ apiEndPoint: apiEndPoint,
2594
+ token: token,
2595
+ customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto3 = orderData.orderDto) === null || _orderData$orderDto3 === void 0 ? void 0 : _orderData$orderDto3.customerId
2687
2596
  })).then(function (data) {
2688
- setCustomerCreditCards(data);
2597
+ setCustomerCreditCards(normalizeSavedCreditCards(data));
2689
2598
  setCardLoading(API_STATUSES.SUCCESS);
2690
2599
  });
2691
2600
  }, function () {
@@ -2698,7 +2607,7 @@ var PaymentModal = function PaymentModal(_ref) {
2698
2607
  })();
2699
2608
  }
2700
2609
  }
2701
- }, [paymentModeId, listUpdate, defaultPaymentProvider]);
2610
+ }, [paymentModeId, listUpdate, paymentProvider, orderData, hasSavedCardProvider]);
2702
2611
  React.useEffect(function () {
2703
2612
  if (!lodash.includes(lodash.values(CARD_METHODS), paymentModeId)) {
2704
2613
  setValue('authorizeDotNetCard', null);
@@ -2713,11 +2622,11 @@ var PaymentModal = function PaymentModal(_ref) {
2713
2622
  };
2714
2623
  setSubmitLoading(true);
2715
2624
  var _temp4 = _catch(function () {
2716
- var _orderData$orderDto3, _orderData$orderDto4, _customerCreditCards$3;
2625
+ var _orderData$orderDto4, _orderData$orderDto5, _customerCreditCards$3;
2717
2626
  var modifyData = lodash.cloneDeep(lodash.omit(_extends({}, formData, {
2718
2627
  status: 'PAID',
2719
- customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto3 = orderData.orderDto) === null || _orderData$orderDto3 === void 0 ? void 0 : _orderData$orderDto3.customerId,
2720
- orderId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto4 = orderData.orderDto) === null || _orderData$orderDto4 === void 0 ? void 0 : _orderData$orderDto4.id,
2628
+ customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto4 = orderData.orderDto) === null || _orderData$orderDto4 === void 0 ? void 0 : _orderData$orderDto4.customerId,
2629
+ orderId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto5 = orderData.orderDto) === null || _orderData$orderDto5 === void 0 ? void 0 : _orderData$orderDto5.id,
2721
2630
  storeId: storeId || 2,
2722
2631
  authorizeDotNetCustomerPaymentProfileId: authorizeDotNetCardData === null || authorizeDotNetCardData === void 0 ? void 0 : authorizeDotNetCardData.customerPaymentProfileId,
2723
2632
  authorizeDotNetCustomerProfileId: customerCreditCards === null || customerCreditCards === void 0 ? void 0 : (_customerCreditCards$3 = customerCreditCards.profile) === null || _customerCreditCards$3 === void 0 ? void 0 : _customerCreditCards$3.customerProfileId
@@ -2742,6 +2651,7 @@ var PaymentModal = function PaymentModal(_ref) {
2742
2651
  };
2743
2652
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, openAddNewCardModal && /*#__PURE__*/React__default.createElement(AddAuthorizeDotNetCard, {
2744
2653
  apiEndPoint: apiEndPoint,
2654
+ paymentProvider: paymentProvider,
2745
2655
  token: token,
2746
2656
  visible: openAddNewCardModal,
2747
2657
  onCancel: function onCancel() {
@@ -2752,7 +2662,7 @@ var PaymentModal = function PaymentModal(_ref) {
2752
2662
  return Promise.reject(e);
2753
2663
  }
2754
2664
  },
2755
- customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto5 = orderData.orderDto) === null || _orderData$orderDto5 === void 0 ? void 0 : _orderData$orderDto5.customerId,
2665
+ customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto6 = orderData.orderDto) === null || _orderData$orderDto6 === void 0 ? void 0 : _orderData$orderDto6.customerId,
2756
2666
  setListUpdate: setListUpdate,
2757
2667
  styles: styles
2758
2668
  }), visible && /*#__PURE__*/React__default.createElement(MuiModal, _extends({
@@ -2782,7 +2692,7 @@ var PaymentModal = function PaymentModal(_ref) {
2782
2692
  },
2783
2693
  loading: submitLoading,
2784
2694
  onClick: handleSubmit(onSubmit),
2785
- disabled: !authorizeDotNetCard || (orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto6 = orderData.orderDto) === null || _orderData$orderDto6 === void 0 ? void 0 : _orderData$orderDto6.dueAmount) <= 0
2695
+ disabled: !authorizeDotNetCard || (orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto7 = orderData.orderDto) === null || _orderData$orderDto7 === void 0 ? void 0 : _orderData$orderDto7.dueAmount) <= 0
2786
2696
  }, "Save")), /*#__PURE__*/React__default.createElement(material.Grid, {
2787
2697
  item: true
2788
2698
  }, /*#__PURE__*/React__default.createElement(MuiButton, {
@@ -2805,13 +2715,13 @@ var PaymentModal = function PaymentModal(_ref) {
2805
2715
  xs: 12,
2806
2716
  md: 6,
2807
2717
  lg: 3
2808
- }, /*#__PURE__*/React__default.createElement("h2", null, "Order #", orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto7 = orderData.orderDto) === null || _orderData$orderDto7 === void 0 ? void 0 : _orderData$orderDto7.id)), /*#__PURE__*/React__default.createElement(material.Grid, {
2718
+ }, /*#__PURE__*/React__default.createElement("h2", null, "Order #", orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto8 = orderData.orderDto) === null || _orderData$orderDto8 === void 0 ? void 0 : _orderData$orderDto8.id)), /*#__PURE__*/React__default.createElement(material.Grid, {
2809
2719
  item: true,
2810
2720
  xs: 12,
2811
2721
  md: 6,
2812
2722
  lg: 3
2813
2723
  }, /*#__PURE__*/React__default.createElement("p", null, getLocalTime({
2814
- time: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto8 = orderData.orderDto) === null || _orderData$orderDto8 === void 0 ? void 0 : _orderData$orderDto8.insertedTimestamp
2724
+ time: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto9 = orderData.orderDto) === null || _orderData$orderDto9 === void 0 ? void 0 : _orderData$orderDto9.insertedTimestamp
2815
2725
  }))), /*#__PURE__*/React__default.createElement(material.Grid, {
2816
2726
  item: true,
2817
2727
  xs: 12,
@@ -2822,7 +2732,7 @@ var PaymentModal = function PaymentModal(_ref) {
2822
2732
  xs: 12,
2823
2733
  md: 6,
2824
2734
  lg: 3
2825
- }, /*#__PURE__*/React__default.createElement("h2", null, "Due Amount: ", renderMoney(orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto9 = orderData.orderDto) === null || _orderData$orderDto9 === void 0 ? void 0 : _orderData$orderDto9.dueAmount))))), /*#__PURE__*/React__default.createElement("form", null, /*#__PURE__*/React__default.createElement(material.Grid, {
2735
+ }, /*#__PURE__*/React__default.createElement("h2", null, "Due Amount: ", renderMoney(orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto10 = orderData.orderDto) === null || _orderData$orderDto10 === void 0 ? void 0 : _orderData$orderDto10.dueAmount))))), /*#__PURE__*/React__default.createElement("form", null, /*#__PURE__*/React__default.createElement(material.Grid, {
2826
2736
  container: true,
2827
2737
  spacing: 2
2828
2738
  }, /*#__PURE__*/React__default.createElement(material.Grid, {
@@ -2837,8 +2747,8 @@ var PaymentModal = function PaymentModal(_ref) {
2837
2747
  disabled: true,
2838
2748
  control: control,
2839
2749
  fontColor: styles === null || styles === void 0 ? void 0 : styles.fontColor,
2840
- max: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto10 = orderData.orderDto) === null || _orderData$orderDto10 === void 0 ? void 0 : _orderData$orderDto10.dueAmount
2841
- })), defaultPaymentProvider === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET && lodash.includes(lodash.values(CARD_METHODS), paymentModeId) && /*#__PURE__*/React__default.createElement(material.Grid, {
2750
+ max: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto11 = orderData.orderDto) === null || _orderData$orderDto11 === void 0 ? void 0 : _orderData$orderDto11.dueAmount
2751
+ })), hasSavedCardProvider && lodash.includes(lodash.values(CARD_METHODS), paymentModeId) && /*#__PURE__*/React__default.createElement(material.Grid, {
2842
2752
  item: true,
2843
2753
  xs: 12
2844
2754
  }, /*#__PURE__*/React__default.createElement(DataLoader, {
@@ -3304,7 +3214,8 @@ var Dashboard = function Dashboard(_ref) {
3304
3214
  hideTotalCardInDashboardSummary = _ref.hideTotalCardInDashboardSummary,
3305
3215
  _ref$showOnlyRecentOr = _ref.showOnlyRecentOrder,
3306
3216
  showOnlyRecentOrder = _ref$showOnlyRecentOr === void 0 ? false : _ref$showOnlyRecentOr,
3307
- hidePayActionButton = _ref.hidePayActionButton;
3217
+ hidePayActionButton = _ref.hidePayActionButton,
3218
+ paymentProvider = _ref.paymentProvider;
3308
3219
  var _useState = React.useState({}),
3309
3220
  customerData = _useState[0],
3310
3221
  setCustomerData = _useState[1];
@@ -3755,6 +3666,7 @@ var Dashboard = function Dashboard(_ref) {
3755
3666
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, (isPaymentModal === null || isPaymentModal === void 0 ? void 0 : isPaymentModal.open) && /*#__PURE__*/React__default.createElement(PaymentModal, {
3756
3667
  apiEndPoint: apiEndPoint,
3757
3668
  token: token,
3669
+ paymentProvider: paymentProvider,
3758
3670
  storeIdList: storeIdList,
3759
3671
  visible: isPaymentModal === null || isPaymentModal === void 0 ? void 0 : isPaymentModal.open,
3760
3672
  onCancel: function onCancel() {
@@ -6031,9 +5943,12 @@ var AccountDetails = function AccountDetails(_ref) {
6031
5943
  })) === null || _storeData$find === void 0 ? void 0 : _storeData$find.id) || 2),
6032
5944
  defaultStoreId = _useState6[0],
6033
5945
  setDefaultStoreId = _useState6[1];
6034
- var _useState7 = React.useState(false),
6035
- authoriseDotNet = _useState7[0],
6036
- setAuthoriseDotNet = _useState7[1];
5946
+ var _useState7 = React.useState({
5947
+ authoriseDotNet: false,
5948
+ nmi: false
5949
+ }),
5950
+ paymentProvider = _useState7[0],
5951
+ setPaymentProvider = _useState7[1];
6037
5952
  var _useState8 = React.useState({
6038
5953
  primaryColor: primaryColor || '#424242',
6039
5954
  secondaryColor: secondaryColor || '#FFFFFF',
@@ -6100,7 +6015,10 @@ var AccountDetails = function AccountDetails(_ref) {
6100
6015
  apiEndPoint: apiEndPoint,
6101
6016
  token: token
6102
6017
  })).then(function (storeFeature) {
6103
- setAuthoriseDotNet((storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET);
6018
+ setPaymentProvider({
6019
+ authoriseDotNet: (storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET,
6020
+ nmi: (storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.NMI
6021
+ });
6104
6022
  });
6105
6023
  });
6106
6024
  }, function () {});
@@ -6157,7 +6075,8 @@ var AccountDetails = function AccountDetails(_ref) {
6157
6075
  hideDiscountImage: hideDiscountImage,
6158
6076
  imgNotFoundUrl: imgNotFoundUrl,
6159
6077
  hideInvoiceAction: hideInvoiceAction,
6160
- payInvoiceFromDashboard: authoriseDotNet,
6078
+ paymentProvider: paymentProvider,
6079
+ payInvoiceFromDashboard: (paymentProvider === null || paymentProvider === void 0 ? void 0 : paymentProvider.authoriseDotNet) || (paymentProvider === null || paymentProvider === void 0 ? void 0 : paymentProvider.nmi),
6161
6080
  removeSocialLinks: removeSocialLinks,
6162
6081
  hideTotalCardInDashboardSummary: hideTotalCardInDashboardSummary,
6163
6082
  showOnlyRecentOrder: showOnlyRecentOrder,
@@ -6971,9 +6890,11 @@ var MainContainer$2 = styled__default.div(_templateObject2$i || (_templateObject
6971
6890
 
6972
6891
  var _templateObject$s, _templateObject2$j, _templateObject3$d, _templateObject4$a, _templateObject5$6, _templateObject6$4, _templateObject7$3, _templateObject8$3, _templateObject9$3;
6973
6892
  var BrandStock = function BrandStock(_ref) {
6974
- var _Object$keys, _Object$keys2, _data$brands;
6893
+ var _data$brands, _Object$keys, _Object$keys2, _data$brands2;
6975
6894
  var storeData = _ref.storeData,
6976
6895
  apiEndPoint = _ref.apiEndPoint,
6896
+ storeIds = _ref.storeIds,
6897
+ storeId = _ref.storeId,
6977
6898
  _ref$colors = _ref.colors,
6978
6899
  colors = _ref$colors === void 0 ? {
6979
6900
  primaryColor: '#424242'
@@ -6981,60 +6902,123 @@ var BrandStock = function BrandStock(_ref) {
6981
6902
  var _useState = React.useState(_extends({}, storeData)),
6982
6903
  data = _useState[0],
6983
6904
  setData = _useState[1];
6905
+ var _useState2 = React.useState(false),
6906
+ isLoading = _useState2[0],
6907
+ setIsLoading = _useState2[1];
6908
+ var resolvedStoreIds = storeIds || storeId || erCookieStorage.getItem('storeId') || 2;
6984
6909
  React.useEffect(function () {
6985
- (function () {
6910
+ setData(function (prev) {
6911
+ return _extends({}, storeData, {
6912
+ brands: prev === null || prev === void 0 ? void 0 : prev.brands
6913
+ });
6914
+ });
6915
+ }, [storeData]);
6916
+ React.useEffect(function () {
6917
+ var ignore = false;
6918
+ var fetchBrandStock = function fetchBrandStock() {
6986
6919
  try {
6987
- var _temp = _catch(function () {
6988
- return Promise.resolve(API({
6989
- apiEndPoint: apiEndPoint,
6990
- url: "/ecommerce/brand/list?size=9999"
6991
- })).then(function (brandList) {
6992
- setData(_extends({}, data, {
6993
- brands: brandList === null || brandList === void 0 ? void 0 : brandList.content
6994
- }));
6995
- });
6996
- }, function () {});
6997
- return _temp && _temp.then ? _temp.then(function () {}) : void 0;
6998
- } catch (e) {
6999
- Promise.reject(e);
7000
- }
7001
- })();
7002
- }, []);
7003
- var getBrandProducts = React.useCallback(function (_ref2) {
7004
- var brand = _ref2.brand;
7005
- try {
7006
- var storeId = erCookieStorage.getItem('storeId') || 2;
7007
- return Promise.resolve(_catch(function () {
7008
- var data = [];
7009
- return Promise.resolve(API({
7010
- apiEndPoint: apiEndPoint,
7011
- url: "/ecommerce/product/brand?brandIdList=" + (brand === null || brand === void 0 ? void 0 : brand.id) + "&storeIds=" + storeId + "&size=9999"
7012
- })).then(function (products) {
7013
- function _temp3() {
7014
- return Promise.resolve(Promise.all(updatePromises)).then(function () {
7015
- return data;
7016
- });
7017
- }
7018
- data = products === null || products === void 0 ? void 0 : products.content;
7019
- var updatePromises = [];
7020
- var _temp2 = _forOf(products === null || products === void 0 ? void 0 : products.content, function (product) {
6920
+ setIsLoading(true);
6921
+ return Promise.resolve(_finallyRethrows(function () {
6922
+ return _catch(function () {
7021
6923
  return Promise.resolve(API({
7022
6924
  apiEndPoint: apiEndPoint,
7023
- url: "/ecommerce/product/" + (product === null || product === void 0 ? void 0 : product.productId) + "?storeIds=" + storeId
7024
- })).then(function (childProducts) {
7025
- var _childProducts$body;
7026
- product.childProducts = (childProducts === null || childProducts === void 0 ? void 0 : (_childProducts$body = childProducts.body) === null || _childProducts$body === void 0 ? void 0 : _childProducts$body.content) || [];
6925
+ url: "/ecommerce/product/brandProductStock?storeIds=" + resolvedStoreIds + "&page=0&size=9999"
6926
+ })).then(function (brandList) {
6927
+ if (ignore) {
6928
+ return;
6929
+ }
6930
+ var content = Array.isArray(brandList === null || brandList === void 0 ? void 0 : brandList.content) ? brandList.content : Array.isArray(brandList) ? brandList : [];
6931
+ setData(function (prev) {
6932
+ return _extends({}, prev, {
6933
+ brands: content
6934
+ });
6935
+ });
7027
6936
  });
6937
+ }, function () {
6938
+ if (!ignore) {
6939
+ setData(function (prev) {
6940
+ return _extends({}, prev, {
6941
+ brands: []
6942
+ });
6943
+ });
6944
+ }
7028
6945
  });
7029
- return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
7030
- });
7031
- }, function () {
7032
- return [];
6946
+ }, function (_wasThrown, _result) {
6947
+ if (!ignore) {
6948
+ setIsLoading(false);
6949
+ }
6950
+ if (_wasThrown) throw _result;
6951
+ return _result;
6952
+ }));
6953
+ } catch (e) {
6954
+ return Promise.reject(e);
6955
+ }
6956
+ };
6957
+ fetchBrandStock();
6958
+ return function () {
6959
+ ignore = true;
6960
+ };
6961
+ }, [apiEndPoint, resolvedStoreIds]);
6962
+ var brandList = data === null || data === void 0 ? void 0 : (_data$brands = data.brands) === null || _data$brands === void 0 ? void 0 : _data$brands.map(function (brand, i) {
6963
+ var _brand$brandAttachmen, _brand$brandAttachmen2;
6964
+ var products = brand === null || brand === void 0 ? void 0 : brand.products;
6965
+ return /*#__PURE__*/React__default.createElement("div", {
6966
+ style: {
6967
+ margin: '1.2rem 0'
6968
+ },
6969
+ key: (brand === null || brand === void 0 ? void 0 : brand.id) || i
6970
+ }, /*#__PURE__*/React__default.createElement(BrandContainer, null, brand === null || brand === void 0 ? void 0 : (_brand$brandAttachmen = brand.brandAttachmentMap) === null || _brand$brandAttachmen === void 0 ? void 0 : (_brand$brandAttachmen2 = _brand$brandAttachmen['Brand Banner']) === null || _brand$brandAttachmen2 === void 0 ? void 0 : _brand$brandAttachmen2.map(function (brand, i) {
6971
+ return /*#__PURE__*/React__default.createElement("div", {
6972
+ style: {
6973
+ display: 'flex'
6974
+ },
6975
+ key: i
6976
+ }, /*#__PURE__*/React__default.createElement("img", {
6977
+ className: "brandImage",
6978
+ alt: "logo",
6979
+ src: (brand === null || brand === void 0 ? void 0 : brand.url) || noImgAvailable$1
7033
6980
  }));
7034
- } catch (e) {
7035
- return Promise.reject(e);
7036
- }
7037
- }, []);
6981
+ }), /*#__PURE__*/React__default.createElement("div", {
6982
+ style: {
6983
+ marginBottom: '0.4rem',
6984
+ textAlign: 'center'
6985
+ }
6986
+ }, /*#__PURE__*/React__default.createElement("p", {
6987
+ style: {
6988
+ fontWeight: 600
6989
+ }
6990
+ }, brand === null || brand === void 0 ? void 0 : brand.name), (brand === null || brand === void 0 ? void 0 : brand.caseQuantity) && /*#__PURE__*/React__default.createElement("p", null, "Case quantity: ", (brand === null || brand === void 0 ? void 0 : brand.caseQuantity) || 'N/A')), /*#__PURE__*/React__default.createElement(TablePaperContainer, {
6991
+ component: Paper
6992
+ }, /*#__PURE__*/React__default.createElement(Table, {
6993
+ "aria-label": "simple table",
6994
+ size: "small"
6995
+ }, /*#__PURE__*/React__default.createElement(TableHead, null, /*#__PURE__*/React__default.createElement(TableRow, null, /*#__PURE__*/React__default.createElement(TableCell, null, /*#__PURE__*/React__default.createElement("b", null, "Product Name")), /*#__PURE__*/React__default.createElement(TableCell, {
6996
+ align: "right"
6997
+ }, /*#__PURE__*/React__default.createElement("b", null, "Stock")))), /*#__PURE__*/React__default.createElement(TableBody, null, (products === null || products === void 0 ? void 0 : products.length) > 0 ? products === null || products === void 0 ? void 0 : products.map(function (product, i) {
6998
+ var _product$childProduct, _product$childProduct2;
6999
+ return (product === null || product === void 0 ? void 0 : (_product$childProduct = product.childProducts) === null || _product$childProduct === void 0 ? void 0 : _product$childProduct.length) > 0 ? product === null || product === void 0 ? void 0 : (_product$childProduct2 = product.childProducts) === null || _product$childProduct2 === void 0 ? void 0 : _product$childProduct2.map(function (child, i) {
7000
+ return /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7001
+ key: i,
7002
+ availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7003
+ }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7004
+ availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7005
+ }, (child === null || child === void 0 ? void 0 : child.productName) || (child === null || child === void 0 ? void 0 : child.name)), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7006
+ align: "right",
7007
+ availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0,
7008
+ stockCol: true
7009
+ }, child.availableQuantity > 0 ? 'In Stock' : 'Out of Stock'));
7010
+ }) : /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7011
+ key: i,
7012
+ availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7013
+ }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7014
+ availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7015
+ }, (product === null || product === void 0 ? void 0 : product.productName) || (product === null || product === void 0 ? void 0 : product.name)), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7016
+ align: "right",
7017
+ availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0,
7018
+ stockCol: true
7019
+ }, (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0 ? 'In Stock' : 'Out of Stock'));
7020
+ }) : /*#__PURE__*/React__default.createElement(TableRow, null, /*#__PURE__*/React__default.createElement(TableCell, null, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("p", null, "No Data Found"))), /*#__PURE__*/React__default.createElement(TableCell, null)))))));
7021
+ });
7038
7022
  return /*#__PURE__*/React__default.createElement(styled.ThemeProvider, {
7039
7023
  theme: colors
7040
7024
  }, /*#__PURE__*/React__default.createElement(Root$9, null, /*#__PURE__*/React__default.createElement(material.CssBaseline, null), /*#__PURE__*/React__default.createElement(TitleContainer$1, null, /*#__PURE__*/React__default.createElement("p", null, "Product stock sheet"), /*#__PURE__*/React__default.createElement("span", null, "Updated automatically every 5 minutes")), /*#__PURE__*/React__default.createElement(MainContainer$3, null, (data === null || data === void 0 ? void 0 : data.logoUrl) && /*#__PURE__*/React__default.createElement("div", {
@@ -7055,74 +7039,9 @@ var BrandStock = function BrandStock(_ref) {
7055
7039
  key: i,
7056
7040
  className: "lineContainer"
7057
7041
  }, /*#__PURE__*/React__default.createElement("span", null, convertToTitleCase(info), ": "), /*#__PURE__*/React__default.createElement("p", null, data === null || data === void 0 ? void 0 : (_data$contactPerson = data.contactPerson) === null || _data$contactPerson === void 0 ? void 0 : _data$contactPerson[info]));
7058
- }))), /*#__PURE__*/React__default.createElement("div", null, data === null || data === void 0 ? void 0 : (_data$brands = data.brands) === null || _data$brands === void 0 ? void 0 : _data$brands.map(function (brand, i) {
7059
- return /*#__PURE__*/React__default.createElement("div", {
7060
- style: {
7061
- margin: '1.2rem 0'
7062
- },
7063
- key: i
7064
- }, /*#__PURE__*/React__default.createElement(AsyncDataLoadComponent, {
7065
- apiEndPoint: apiEndPoint,
7066
- asyncService: function asyncService() {
7067
- return getBrandProducts({
7068
- brand: brand
7069
- });
7070
- }
7071
- }, function (products) {
7072
- var _brand$brandAttachmen, _brand$brandAttachmen2;
7073
- return /*#__PURE__*/React__default.createElement(BrandContainer, null, brand === null || brand === void 0 ? void 0 : (_brand$brandAttachmen = brand.brandAttachmentMap) === null || _brand$brandAttachmen === void 0 ? void 0 : (_brand$brandAttachmen2 = _brand$brandAttachmen['Brand Banner']) === null || _brand$brandAttachmen2 === void 0 ? void 0 : _brand$brandAttachmen2.map(function (brand, i) {
7074
- return /*#__PURE__*/React__default.createElement("div", {
7075
- style: {
7076
- display: 'flex'
7077
- },
7078
- key: i
7079
- }, /*#__PURE__*/React__default.createElement("img", {
7080
- className: "brandImage",
7081
- alt: "logo",
7082
- src: (brand === null || brand === void 0 ? void 0 : brand.url) || noImgAvailable$1
7083
- }));
7084
- }), /*#__PURE__*/React__default.createElement("div", {
7085
- style: {
7086
- marginBottom: '0.4rem',
7087
- textAlign: 'center'
7088
- }
7089
- }, /*#__PURE__*/React__default.createElement("p", {
7090
- style: {
7091
- fontWeight: 600
7092
- }
7093
- }, brand === null || brand === void 0 ? void 0 : brand.name), (brand === null || brand === void 0 ? void 0 : brand.caseQuantity) && /*#__PURE__*/React__default.createElement("p", null, "Case quantity: ", (brand === null || brand === void 0 ? void 0 : brand.caseQuantity) || 'N/A')), /*#__PURE__*/React__default.createElement(TablePaperContainer, {
7094
- component: Paper
7095
- }, /*#__PURE__*/React__default.createElement(Table, {
7096
- "aria-label": "simple table",
7097
- size: "small"
7098
- }, /*#__PURE__*/React__default.createElement(TableHead, null, /*#__PURE__*/React__default.createElement(TableRow, null, /*#__PURE__*/React__default.createElement(TableCell, null, /*#__PURE__*/React__default.createElement("b", null, "Product Name")), /*#__PURE__*/React__default.createElement(TableCell, {
7099
- align: "right"
7100
- }, /*#__PURE__*/React__default.createElement("b", null, "Stock")))), /*#__PURE__*/React__default.createElement(TableBody, null, (products === null || products === void 0 ? void 0 : products.length) > 0 ? products === null || products === void 0 ? void 0 : products.map(function (product, i) {
7101
- var _product$childProduct, _product$childProduct2;
7102
- return (product === null || product === void 0 ? void 0 : (_product$childProduct = product.childProducts) === null || _product$childProduct === void 0 ? void 0 : _product$childProduct.length) > 0 ? product === null || product === void 0 ? void 0 : (_product$childProduct2 = product.childProducts) === null || _product$childProduct2 === void 0 ? void 0 : _product$childProduct2.map(function (child, i) {
7103
- return /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7104
- key: i,
7105
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7106
- }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7107
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7108
- }, child === null || child === void 0 ? void 0 : child.productName), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7109
- align: "right",
7110
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0,
7111
- stockCol: true
7112
- }, child.availableQuantity > 0 ? 'In Stock' : 'Out of Stock'));
7113
- }) : /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7114
- key: i,
7115
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7116
- }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7117
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7118
- }, product === null || product === void 0 ? void 0 : product.productName), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7119
- align: "right",
7120
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0,
7121
- stockCol: true
7122
- }, (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0 ? 'In Stock' : 'Out of Stock'));
7123
- }) : /*#__PURE__*/React__default.createElement(TableRow, null, /*#__PURE__*/React__default.createElement(TableCell, null, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("p", null, "No Data Found"))), /*#__PURE__*/React__default.createElement(TableCell, null))))));
7124
- }));
7125
- })), (data === null || data === void 0 ? void 0 : data.returnPolicy) && /*#__PURE__*/React__default.createElement(ReturnPolicyContainer, null, /*#__PURE__*/React__default.createElement("h2", null, (data === null || data === void 0 ? void 0 : data.returnPolicyTitle) || 'Return Policy'), data === null || data === void 0 ? void 0 : data.returnPolicy))));
7042
+ }))), /*#__PURE__*/React__default.createElement("div", null, isLoading && !((data === null || data === void 0 ? void 0 : (_data$brands2 = data.brands) === null || _data$brands2 === void 0 ? void 0 : _data$brands2.length) > 0) && /*#__PURE__*/React__default.createElement(Loader, {
7043
+ height: 80
7044
+ }), brandList), (data === null || data === void 0 ? void 0 : data.returnPolicy) && /*#__PURE__*/React__default.createElement(ReturnPolicyContainer, null, /*#__PURE__*/React__default.createElement("h2", null, (data === null || data === void 0 ? void 0 : data.returnPolicyTitle) || 'Return Policy'), data === null || data === void 0 ? void 0 : data.returnPolicy))));
7126
7045
  };
7127
7046
  var Root$9 = styled__default.div(_templateObject$s || (_templateObject$s = _taggedTemplateLiteralLoose(["\n padding: 1rem;\n"])));
7128
7047
  var TitleContainer$1 = styled__default.div(_templateObject2$j || (_templateObject2$j = _taggedTemplateLiteralLoose(["\n padding: 0 1rem;\n display: flex;\n justify-content: space-between;\n"])));
@@ -14623,7 +14542,7 @@ var Step3 = function Step3(_ref) {
14623
14542
  var _customer$customerDto, _selectedMethod$name, _styles$button2;
14624
14543
  var apiEndPoint = _ref.apiEndPoint,
14625
14544
  token = _ref.token,
14626
- authoriseDotNet = _ref.authoriseDotNet,
14545
+ paymentProvider = _ref.paymentProvider,
14627
14546
  handleBack = _ref.handleBack,
14628
14547
  _handleNext = _ref.handleNext,
14629
14548
  setPaymentDetails = _ref.setPaymentDetails,
@@ -14654,7 +14573,7 @@ var Step3 = function Step3(_ref) {
14654
14573
  var _useState5 = React.useState(),
14655
14574
  selectCardValue = _useState5[0],
14656
14575
  setSelectCardValue = _useState5[1];
14657
- var _useState6 = React.useState(authoriseDotNet ? true : false),
14576
+ var _useState6 = React.useState(paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet || paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.nmi ? true : false),
14658
14577
  addNewCard = _useState6[0],
14659
14578
  setAddNewCard = _useState6[1];
14660
14579
  var _useState7 = React.useState(false),
@@ -14672,13 +14591,17 @@ var Step3 = function Step3(_ref) {
14672
14591
  try {
14673
14592
  return _catch(function () {
14674
14593
  var _temp = function () {
14675
- if (customerId && apiEndPoint && token && authoriseDotNet) {
14676
- return Promise.resolve(getAuthorizeDotNetCreditCards({
14594
+ if (customerId && apiEndPoint && token && (paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet || paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.nmi)) {
14595
+ return Promise.resolve(paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet ? getAuthorizeDotNetCreditCards({
14596
+ apiEndPoint: apiEndPoint,
14597
+ token: token,
14598
+ customerId: customerId
14599
+ }) : getNmiCreditCards({
14677
14600
  apiEndPoint: apiEndPoint,
14678
14601
  token: token,
14679
14602
  customerId: customerId
14680
14603
  })).then(function (data) {
14681
- setCreditCardListData(data);
14604
+ setCreditCardListData(normalizeSavedCreditCards(data));
14682
14605
  });
14683
14606
  }
14684
14607
  }();
@@ -15630,9 +15553,12 @@ var CheckoutPageComponentWrapper = function CheckoutPageComponentWrapper(_ref) {
15630
15553
  var _useState4 = React.useState(0),
15631
15554
  currStep = _useState4[0],
15632
15555
  setCurrStep = _useState4[1];
15633
- var _useState5 = React.useState(false),
15634
- authoriseDotNet = _useState5[0],
15635
- setAuthoriseDotNet = _useState5[1];
15556
+ var _useState5 = React.useState({
15557
+ authoriseDotNet: false,
15558
+ nmi: false
15559
+ }),
15560
+ paymentProvider = _useState5[0],
15561
+ setPaymentProvider = _useState5[1];
15636
15562
  var _useState6 = React.useState([]),
15637
15563
  deliveryOptions = _useState6[0],
15638
15564
  setDeliveryOptions = _useState6[1];
@@ -15710,7 +15636,10 @@ var CheckoutPageComponentWrapper = function CheckoutPageComponentWrapper(_ref) {
15710
15636
  apiEndPoint: apiEndPoint,
15711
15637
  token: token
15712
15638
  })).then(function (storeFeature) {
15713
- setAuthoriseDotNet((storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET);
15639
+ setPaymentProvider({
15640
+ authoriseDotNet: (storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET,
15641
+ nmi: (storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.NMI
15642
+ });
15714
15643
  });
15715
15644
  });
15716
15645
  }, function () {});
@@ -16133,7 +16062,7 @@ var CheckoutPageComponentWrapper = function CheckoutPageComponentWrapper(_ref) {
16133
16062
  var orderPaymentList;
16134
16063
  var ecommerceCustomPaymentDto = null;
16135
16064
  if (card) {
16136
- var cardData = authoriseDotNet ? {
16065
+ var cardData = paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet ? {
16137
16066
  firstName: card === null || card === void 0 ? void 0 : card.firstName,
16138
16067
  lastName: card === null || card === void 0 ? void 0 : card.lastName
16139
16068
  } : {
@@ -16350,7 +16279,7 @@ var CheckoutPageComponentWrapper = function CheckoutPageComponentWrapper(_ref) {
16350
16279
  }, /*#__PURE__*/React__default.createElement(Step3, {
16351
16280
  customer: customer,
16352
16281
  apiEndPoint: apiEndPoint,
16353
- authoriseDotNet: authoriseDotNet,
16282
+ paymentProvider: paymentProvider,
16354
16283
  token: token,
16355
16284
  currstep: currStep,
16356
16285
  handleBack: handleBack,
@@ -18464,6 +18393,491 @@ var ProductCard = function ProductCard(_ref4) {
18464
18393
  }, "Out Of stock")));
18465
18394
  };
18466
18395
 
18396
+ var cardStyle$1 = {
18397
+ border: '1px solid #d3d3d3',
18398
+ borderRadius: '10px',
18399
+ display: 'flex',
18400
+ flexDirection: 'column',
18401
+ justifyContent: 'center',
18402
+ alignItems: 'center',
18403
+ padding: '10px',
18404
+ gap: '10px',
18405
+ backgroundColor: '#ffffff'
18406
+ };
18407
+ var FavoriteItemsProductCardSkeleton = function FavoriteItemsProductCardSkeleton(_ref) {
18408
+ var span = _ref.span,
18409
+ _ref$count = _ref.count,
18410
+ count = _ref$count === void 0 ? 18 : _ref$count;
18411
+ return /*#__PURE__*/React__default.createElement(material.Grid, {
18412
+ container: true,
18413
+ spacing: 2
18414
+ }, Array.from({
18415
+ length: count
18416
+ }).map(function (_, i) {
18417
+ var _span$xs, _span$sm, _span$md, _span$lg;
18418
+ return /*#__PURE__*/React__default.createElement(material.Grid, {
18419
+ item: true,
18420
+ xs: (_span$xs = span === null || span === void 0 ? void 0 : span.xs) != null ? _span$xs : 12,
18421
+ sm: (_span$sm = span === null || span === void 0 ? void 0 : span.sm) != null ? _span$sm : 6,
18422
+ md: (_span$md = span === null || span === void 0 ? void 0 : span.md) != null ? _span$md : 4,
18423
+ lg: (_span$lg = span === null || span === void 0 ? void 0 : span.lg) != null ? _span$lg : 2,
18424
+ key: i
18425
+ }, /*#__PURE__*/React__default.createElement("div", {
18426
+ style: cardStyle$1
18427
+ }, /*#__PURE__*/React__default.createElement(material.Skeleton, {
18428
+ variant: "rectangular",
18429
+ width: 160,
18430
+ height: 160,
18431
+ animation: "wave"
18432
+ }), /*#__PURE__*/React__default.createElement(material.Skeleton, {
18433
+ variant: "text",
18434
+ width: 80,
18435
+ height: 24,
18436
+ animation: "wave"
18437
+ }), /*#__PURE__*/React__default.createElement(material.Skeleton, {
18438
+ variant: "text",
18439
+ width: "90%",
18440
+ height: 43,
18441
+ animation: "wave"
18442
+ }), /*#__PURE__*/React__default.createElement(material.Skeleton, {
18443
+ variant: "rectangular",
18444
+ width: 120,
18445
+ height: 36,
18446
+ animation: "wave",
18447
+ sx: {
18448
+ borderRadius: '10px'
18449
+ }
18450
+ })));
18451
+ }));
18452
+ };
18453
+
18454
+ var getFavoriteItemsData = function getFavoriteItemsData(_ref) {
18455
+ var apiEndPoint = _ref.apiEndPoint,
18456
+ token = _ref.token,
18457
+ _ref$queryParams = _ref.queryParams,
18458
+ queryParams = _ref$queryParams === void 0 ? {} : _ref$queryParams;
18459
+ try {
18460
+ if (!apiEndPoint || !token) return Promise.resolve([]);
18461
+ return Promise.resolve(API({
18462
+ apiEndPoint: apiEndPoint,
18463
+ token: token,
18464
+ url: "/ecommerce/favoriteProduct",
18465
+ queryParams: queryParams
18466
+ })).then(function (data) {
18467
+ return data != null ? data : [];
18468
+ });
18469
+ } catch (e) {
18470
+ return Promise.reject(e);
18471
+ }
18472
+ };
18473
+ var removeFromFavoriteItems = function removeFromFavoriteItems(_ref2) {
18474
+ var apiEndPoint = _ref2.apiEndPoint,
18475
+ token = _ref2.token,
18476
+ productId = _ref2.productId;
18477
+ try {
18478
+ var _erCookieStorage$getI;
18479
+ if (!apiEndPoint || !token || productId == null) return Promise.resolve();
18480
+ var storeId = (erCookieStorage === null || erCookieStorage === void 0 ? void 0 : (_erCookieStorage$getI = erCookieStorage.getItem) === null || _erCookieStorage$getI === void 0 ? void 0 : _erCookieStorage$getI.call(erCookieStorage, 'storeId')) || 2;
18481
+ return Promise.resolve(API({
18482
+ apiEndPoint: apiEndPoint,
18483
+ token: token,
18484
+ url: "/ecommerce/favoriteProduct",
18485
+ method: 'delete',
18486
+ queryParams: {
18487
+ productId: productId,
18488
+ storeId: storeId
18489
+ },
18490
+ successMessage: 'Product removed from favorites successfully',
18491
+ errorMessage: 'Error in removing product from favorites'
18492
+ })).then(function () {});
18493
+ } catch (e) {
18494
+ return Promise.reject(e);
18495
+ }
18496
+ };
18497
+ var moveToCartFromFavoriteItems = function moveToCartFromFavoriteItems(_ref3) {
18498
+ var apiEndPoint = _ref3.apiEndPoint,
18499
+ token = _ref3.token,
18500
+ productId = _ref3.productId;
18501
+ try {
18502
+ if (!apiEndPoint || !token || productId == null) return Promise.resolve();
18503
+ return Promise.resolve(API({
18504
+ apiEndPoint: apiEndPoint,
18505
+ token: token,
18506
+ url: "/ecommerce/favoriteProduct/move-to-cart",
18507
+ method: 'post',
18508
+ body: [productId],
18509
+ successMessage: 'Product moved to cart successfully',
18510
+ errorMessage: 'Error in moving product to cart'
18511
+ })).then(function () {});
18512
+ } catch (e) {
18513
+ return Promise.reject(e);
18514
+ }
18515
+ };
18516
+
18517
+ var _templateObject$Y, _templateObject2$G, _templateObject3$w, _templateObject4$q, _templateObject5$l, _templateObject6$j, _templateObject7$f, _templateObject8$d, _templateObject9$9, _templateObject10$7, _templateObject11$6;
18518
+ var EmptyStateText$1 = styled__default.p(_templateObject$Y || (_templateObject$Y = _taggedTemplateLiteralLoose(["\n font-size: 16px;\n color: #4b4b4b;\n margin: 16px 0;\n"])));
18519
+ var ProductCardWrapper$1 = styled__default.div(_templateObject2$G || (_templateObject2$G = _taggedTemplateLiteralLoose(["\n position: relative;\n background-color: #ffffff;\n border: 1px solid #d3d3d3;\n border-radius: 10px;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n padding: 10px;\n gap: 10px;\n cursor: pointer;\n"])));
18520
+ var TopBar$1 = styled__default.div(_templateObject3$w || (_templateObject3$w = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n gap: 12px;\n"])));
18521
+ var SearchWrapper$1 = styled__default(material.Box)(_templateObject4$q || (_templateObject4$q = _taggedTemplateLiteralLoose(["\n && {\n margin-bottom: 24px;\n max-width: 400px;\n width: 100%;\n }\n"])));
18522
+ var TotalItemsText$1 = styled__default.div(_templateObject5$l || (_templateObject5$l = _taggedTemplateLiteralLoose(["\n font-size: 14px;\n font-weight: 500;\n color: #4b4b4b;\n margin-bottom: 24px;\n white-space: nowrap;\n"])));
18523
+ var DeleteButton$1 = styled__default.button(_templateObject6$j || (_templateObject6$j = _taggedTemplateLiteralLoose(["\n position: absolute;\n top: 8px;\n right: 8px;\n opacity: 1;\n pointer-events: auto;\n z-index: 2;\n display: flex;\n align-items: center;\n justify-content: center;\n width: 32px;\n height: 32px;\n padding: 0;\n border: none;\n border-radius: 50%;\n background-color: #ffffff;\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);\n cursor: pointer;\n color: #ff0000;\n"])));
18524
+ var PriceContainer$1 = styled__default.div(_templateObject7$f || (_templateObject7$f = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n"])));
18525
+ var DiscountPriceRow$1 = styled__default.div(_templateObject8$d || (_templateObject8$d = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n"])));
18526
+ var ProductName$3 = styled__default.div(_templateObject9$9 || (_templateObject9$9 = _taggedTemplateLiteralLoose(["\n font-size: 16px;\n font-weight: 500;\n color: #000000;\n text-align: center;\n height: 40px;\n overflow: hidden;\n width: 100%;\n text-overflow: ellipsis;\n white-space: pre-wrap;\n"])));
18527
+ var ProductActionButton$1 = styled__default(material.Button)(_templateObject10$7 || (_templateObject10$7 = _taggedTemplateLiteralLoose(["\n && {\n background-color: ", ";\n color: #ffffff;\n border-radius: 10px;\n font-weight: 500;\n }\n"])), function (_ref) {
18528
+ var primaryColor = _ref.primaryColor;
18529
+ return primaryColor != null ? primaryColor : '#000000';
18530
+ });
18531
+ var OutOfStockButton$1 = styled__default(material.Button)(_templateObject11$6 || (_templateObject11$6 = _taggedTemplateLiteralLoose(["\n && {\n color: #ffffff;\n border-radius: 10px;\n font-weight: 500;\n }\n"])));
18532
+
18533
+ var getProductImage$1 = function getProductImage(imageUrl, fallbackUrl) {
18534
+ var url = imageUrl || fallbackUrl;
18535
+ return url && url !== 'null' ? url : '/images/products/imgnotfound.png';
18536
+ };
18537
+ var formatPrice$1 = function formatPrice(price) {
18538
+ var value = Number(price);
18539
+ return Number.isFinite(value) ? value.toFixed(2) : '0.00';
18540
+ };
18541
+ var DEFAULT_GRID_SPAN$1 = {
18542
+ lg: 3,
18543
+ md: 4,
18544
+ sm: 6,
18545
+ xs: 6
18546
+ };
18547
+ var getStyleOverride$1 = function getStyleOverride(styleOverrides) {
18548
+ for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
18549
+ keys[_key - 1] = arguments[_key];
18550
+ }
18551
+ for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
18552
+ var key = _keys[_i];
18553
+ if (styleOverrides !== null && styleOverrides !== void 0 && styleOverrides[key]) return styleOverrides[key];
18554
+ }
18555
+ return undefined;
18556
+ };
18557
+ var normalizeFavoriteItems = function normalizeFavoriteItems(data) {
18558
+ if (Array.isArray(data)) return data.filter(Boolean);
18559
+ var content = data === null || data === void 0 ? void 0 : data.content;
18560
+ return Array.isArray(content) ? content.filter(Boolean) : [];
18561
+ };
18562
+ var getFavoriteItemsTotal = function getFavoriteItemsTotal(data, items) {
18563
+ var _items$length;
18564
+ if (typeof (data === null || data === void 0 ? void 0 : data.totalElements) === 'number') {
18565
+ return data === null || data === void 0 ? void 0 : data.totalElements;
18566
+ }
18567
+ return (_items$length = items === null || items === void 0 ? void 0 : items.length) != null ? _items$length : 0;
18568
+ };
18569
+ var FavoriteItemsContent = function FavoriteItemsContent(_ref) {
18570
+ var data = _ref.data,
18571
+ apiEndPoint = _ref.apiEndPoint,
18572
+ token = _ref.token,
18573
+ searchInput = _ref.searchInput,
18574
+ onSearchChange = _ref.onSearchChange,
18575
+ styleOverrides = _ref.styleOverrides,
18576
+ gridSpan = _ref.gridSpan,
18577
+ primaryColor = _ref.primaryColor,
18578
+ onMoveToCart = _ref.onMoveToCart,
18579
+ onProductCardClick = _ref.onProductCardClick,
18580
+ _ref$imgNotFoundUrl = _ref.imgNotFoundUrl,
18581
+ imgNotFoundUrl = _ref$imgNotFoundUrl === void 0 ? '' : _ref$imgNotFoundUrl,
18582
+ setRefreshTrigger = _ref.setRefreshTrigger,
18583
+ allowToProcessInvoiceForOutOfStockProducts = _ref.allowToProcessInvoiceForOutOfStockProducts;
18584
+ var items = React.useMemo(function () {
18585
+ return normalizeFavoriteItems(data);
18586
+ }, [data]);
18587
+ var totalItems = React.useMemo(function () {
18588
+ return getFavoriteItemsTotal(data, items);
18589
+ }, [data, items]);
18590
+ return /*#__PURE__*/React__default.createElement("div", {
18591
+ style: {
18592
+ width: '100%',
18593
+ height: '100%'
18594
+ }
18595
+ }, /*#__PURE__*/React__default.createElement(TopBar$1, {
18596
+ style: getStyleOverride$1(styleOverrides, 'topBar', 'TopBar')
18597
+ }, /*#__PURE__*/React__default.createElement(SearchWrapper$1, {
18598
+ style: getStyleOverride$1(styleOverrides, 'searchWrapper', 'SearchWrapper')
18599
+ }, /*#__PURE__*/React__default.createElement(material.TextField, {
18600
+ placeholder: "Type minimum 3 characters to search...",
18601
+ value: searchInput,
18602
+ onChange: onSearchChange,
18603
+ size: "small",
18604
+ fullWidth: true,
18605
+ sx: {
18606
+ '& .MuiOutlinedInput-root': {
18607
+ borderRadius: '8px'
18608
+ }
18609
+ }
18610
+ })), /*#__PURE__*/React__default.createElement(TotalItemsText$1, {
18611
+ style: getStyleOverride$1(styleOverrides, 'totalItemsText', 'TotalItemsText')
18612
+ }, "Total " + totalItems + " item" + (totalItems === 1 ? '' : 's'))), !(items !== null && items !== void 0 && items.length) ? /*#__PURE__*/React__default.createElement(EmptyStateText$1, {
18613
+ style: getStyleOverride$1(styleOverrides, 'emptyStateText', 'EmptyStateText')
18614
+ }, "No favorite items found") : /*#__PURE__*/React__default.createElement(material.Grid, {
18615
+ container: true,
18616
+ spacing: 2
18617
+ }, items === null || items === void 0 ? void 0 : items.map(function (product, index) {
18618
+ var _ref2, _product$id;
18619
+ return /*#__PURE__*/React__default.createElement(material.Grid, {
18620
+ item: true,
18621
+ xs: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.xs,
18622
+ sm: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.sm,
18623
+ md: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.md,
18624
+ lg: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.lg,
18625
+ key: (_ref2 = (_product$id = product === null || product === void 0 ? void 0 : product.id) != null ? _product$id : product === null || product === void 0 ? void 0 : product.productId) != null ? _ref2 : index
18626
+ }, /*#__PURE__*/React__default.createElement(ProductCard$1, {
18627
+ setRefreshTrigger: setRefreshTrigger,
18628
+ apiEndPoint: apiEndPoint,
18629
+ token: token,
18630
+ product: product,
18631
+ styleOverrides: styleOverrides,
18632
+ primaryColor: primaryColor,
18633
+ onMoveToCart: onMoveToCart,
18634
+ onProductCardClick: onProductCardClick,
18635
+ imgNotFoundUrl: imgNotFoundUrl,
18636
+ allowToProcessInvoiceForOutOfStockProducts: allowToProcessInvoiceForOutOfStockProducts
18637
+ }));
18638
+ })));
18639
+ };
18640
+ var FavoriteItemsComponent = function FavoriteItemsComponent(_ref3) {
18641
+ var _ref3$style = _ref3.style,
18642
+ style = _ref3$style === void 0 ? {} : _ref3$style,
18643
+ token = _ref3.token,
18644
+ _ref3$span = _ref3.span,
18645
+ span = _ref3$span === void 0 ? DEFAULT_GRID_SPAN$1 : _ref3$span,
18646
+ primaryColor = _ref3.primaryColor,
18647
+ apiEndPoint = _ref3.apiEndPoint,
18648
+ onMoveToCart = _ref3.onMoveToCart,
18649
+ onProductCardClick = _ref3.onProductCardClick,
18650
+ _ref3$allowToProcessI = _ref3.allowToProcessInvoiceForOutOfStockProducts,
18651
+ allowToProcessInvoiceForOutOfStockProducts = _ref3$allowToProcessI === void 0 ? false : _ref3$allowToProcessI;
18652
+ var styleOverrides = React.useMemo(function () {
18653
+ return _extends({}, style || {});
18654
+ }, [style]);
18655
+ var _useState = React.useState(''),
18656
+ searchInput = _useState[0],
18657
+ setSearchInput = _useState[1];
18658
+ var _useState2 = React.useState(''),
18659
+ searchQuery = _useState2[0],
18660
+ setSearchQuery = _useState2[1];
18661
+ var _useState3 = React.useState(0),
18662
+ refreshTrigger = _useState3[0],
18663
+ setRefreshTrigger = _useState3[1];
18664
+ var gridSpan = React.useMemo(function () {
18665
+ return _extends({}, DEFAULT_GRID_SPAN$1, span || {});
18666
+ }, [span]);
18667
+ var debouncedSearch = React.useMemo(function () {
18668
+ return debounce$1(function (value) {
18669
+ var normalizedValue = value != null ? value : '';
18670
+ if ((normalizedValue === null || normalizedValue === void 0 ? void 0 : normalizedValue.length) === 0 || (normalizedValue === null || normalizedValue === void 0 ? void 0 : normalizedValue.length) >= 3) {
18671
+ setSearchQuery(normalizedValue);
18672
+ }
18673
+ }, 500);
18674
+ }, []);
18675
+ React.useEffect(function () {
18676
+ return function () {
18677
+ var _debouncedSearch$canc;
18678
+ debouncedSearch === null || debouncedSearch === void 0 ? void 0 : (_debouncedSearch$canc = debouncedSearch.cancel) === null || _debouncedSearch$canc === void 0 ? void 0 : _debouncedSearch$canc.call(debouncedSearch);
18679
+ };
18680
+ }, [debouncedSearch]);
18681
+ var handleSearchChange = React.useCallback(function (e) {
18682
+ var _e$target$value, _e$target;
18683
+ var value = (_e$target$value = e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.value) != null ? _e$target$value : '';
18684
+ setSearchInput(value);
18685
+ debouncedSearch(value);
18686
+ }, [debouncedSearch]);
18687
+ var favoriteItemsTrigger = React.useMemo(function () {
18688
+ return searchQuery + "-" + refreshTrigger;
18689
+ }, [searchQuery, refreshTrigger]);
18690
+ var favoriteItemsAsyncService = React.useCallback(function () {
18691
+ return getFavoriteItemsData({
18692
+ apiEndPoint: apiEndPoint,
18693
+ token: token,
18694
+ queryParams: _extends({
18695
+ page: 0,
18696
+ size: 9999
18697
+ }, searchQuery ? {
18698
+ productName: searchQuery
18699
+ } : {})
18700
+ });
18701
+ }, [apiEndPoint, token, searchQuery]);
18702
+ var favoriteItemsLoadingView = React.useMemo(function () {
18703
+ return /*#__PURE__*/React__default.createElement(FavoriteItemsProductCardSkeleton, {
18704
+ span: span
18705
+ });
18706
+ }, [span]);
18707
+ if (!token) {
18708
+ return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("h1", null, "Favorite Items"), /*#__PURE__*/React__default.createElement("p", null, "Please log in to view your favorite items."));
18709
+ }
18710
+ if (!apiEndPoint) {
18711
+ return /*#__PURE__*/React__default.createElement(EmptyStateText$1, null, "Unable to load favorite items. API endpoint is not configured.");
18712
+ }
18713
+ return /*#__PURE__*/React__default.createElement("div", {
18714
+ style: {
18715
+ marginTop: '1rem',
18716
+ height: '100%',
18717
+ width: '100%'
18718
+ }
18719
+ }, /*#__PURE__*/React__default.createElement(AsyncDataLoadComponent, {
18720
+ asyncService: favoriteItemsAsyncService,
18721
+ triggerChange: favoriteItemsTrigger,
18722
+ loadingView: favoriteItemsLoadingView
18723
+ }, function (data) {
18724
+ return /*#__PURE__*/React__default.createElement(FavoriteItemsContent, {
18725
+ data: data,
18726
+ apiEndPoint: apiEndPoint,
18727
+ token: token,
18728
+ searchInput: searchInput,
18729
+ onSearchChange: handleSearchChange,
18730
+ styleOverrides: styleOverrides,
18731
+ gridSpan: gridSpan,
18732
+ primaryColor: primaryColor,
18733
+ onMoveToCart: onMoveToCart,
18734
+ onProductCardClick: onProductCardClick,
18735
+ setRefreshTrigger: setRefreshTrigger,
18736
+ allowToProcessInvoiceForOutOfStockProducts: allowToProcessInvoiceForOutOfStockProducts
18737
+ });
18738
+ }));
18739
+ };
18740
+ var ProductCard$1 = function ProductCard(_ref4) {
18741
+ var _product$standardPric, _product$retailPrice;
18742
+ var product = _ref4.product,
18743
+ styleOverrides = _ref4.styleOverrides,
18744
+ primaryColor = _ref4.primaryColor,
18745
+ onMoveToCart = _ref4.onMoveToCart,
18746
+ onProductCardClick = _ref4.onProductCardClick,
18747
+ _ref4$imgNotFoundUrl = _ref4.imgNotFoundUrl,
18748
+ imgNotFoundUrl = _ref4$imgNotFoundUrl === void 0 ? '' : _ref4$imgNotFoundUrl,
18749
+ apiEndPoint = _ref4.apiEndPoint,
18750
+ token = _ref4.token,
18751
+ setRefreshTrigger = _ref4.setRefreshTrigger,
18752
+ allowToProcessInvoiceForOutOfStockProducts = _ref4.allowToProcessInvoiceForOutOfStockProducts;
18753
+ var _useState4 = React.useState(false),
18754
+ deleteLoading = _useState4[0],
18755
+ setDeleteLoading = _useState4[1];
18756
+ var _useState5 = React.useState(false),
18757
+ moveToCartLoading = _useState5[0],
18758
+ setMoveToCartLoading = _useState5[1];
18759
+ if (!product) return null;
18760
+ var removeItem = function removeItem(item) {
18761
+ try {
18762
+ if ((item === null || item === void 0 ? void 0 : item.productId) == null) return Promise.resolve();
18763
+ setDeleteLoading(true);
18764
+ var _temp = _finallyRethrows(function () {
18765
+ return _catch(function () {
18766
+ return Promise.resolve(removeFromFavoriteItems({
18767
+ apiEndPoint: apiEndPoint,
18768
+ token: token,
18769
+ productId: item === null || item === void 0 ? void 0 : item.productId
18770
+ })).then(function () {
18771
+ setRefreshTrigger === null || setRefreshTrigger === void 0 ? void 0 : setRefreshTrigger(function (prev) {
18772
+ return prev + 1;
18773
+ });
18774
+ });
18775
+ }, function () {});
18776
+ }, function (_wasThrown, _result) {
18777
+ setDeleteLoading(false);
18778
+ if (_wasThrown) throw _result;
18779
+ return _result;
18780
+ });
18781
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
18782
+ } catch (e) {
18783
+ return Promise.reject(e);
18784
+ }
18785
+ };
18786
+ return /*#__PURE__*/React__default.createElement(ProductCardWrapper$1, {
18787
+ style: getStyleOverride$1(styleOverrides, 'productCardWrapper', 'ProductCardWrapper'),
18788
+ onClick: function onClick() {
18789
+ onProductCardClick === null || onProductCardClick === void 0 ? void 0 : onProductCardClick(product);
18790
+ }
18791
+ }, /*#__PURE__*/React__default.createElement(DeleteButton$1, {
18792
+ type: "button",
18793
+ className: "favorite-items-delete-btn",
18794
+ "aria-label": "Remove from favorites",
18795
+ style: getStyleOverride$1(styleOverrides, 'deleteButton', 'DeleteButton'),
18796
+ onClick: function onClick(e) {
18797
+ try {
18798
+ var _e$stopPropagation;
18799
+ e === null || e === void 0 ? void 0 : (_e$stopPropagation = e.stopPropagation) === null || _e$stopPropagation === void 0 ? void 0 : _e$stopPropagation.call(e);
18800
+ return Promise.resolve(_catch(function () {
18801
+ var _window, _window$confirm;
18802
+ var confirm = (_window = window) === null || _window === void 0 ? void 0 : (_window$confirm = _window.confirm) === null || _window$confirm === void 0 ? void 0 : _window$confirm.call(_window, 'Are you sure you want to remove this item from favorites?');
18803
+ if (!confirm) return;
18804
+ return Promise.resolve(removeItem(product)).then(function () {});
18805
+ }, function () {}));
18806
+ } catch (e) {
18807
+ return Promise.reject(e);
18808
+ }
18809
+ }
18810
+ }, deleteLoading ? /*#__PURE__*/React__default.createElement(material.CircularProgress, {
18811
+ size: 20
18812
+ }) : /*#__PURE__*/React__default.createElement(ai.AiOutlineDelete, {
18813
+ style: {
18814
+ fontSize: 18
18815
+ }
18816
+ })), /*#__PURE__*/React__default.createElement(Image$3, {
18817
+ src: getProductImage$1(product === null || product === void 0 ? void 0 : product.imageUrl, imgNotFoundUrl),
18818
+ alt: (product === null || product === void 0 ? void 0 : product.productName) || 'Product',
18819
+ width: 160,
18820
+ height: 160,
18821
+ objectFit: "contain"
18822
+ }), /*#__PURE__*/React__default.createElement(PriceContainer$1, {
18823
+ style: getStyleOverride$1(styleOverrides, 'priceContainer', 'PriceContainer')
18824
+ }, ((_product$standardPric = product === null || product === void 0 ? void 0 : product.standardPrice) != null ? _product$standardPric : 0) > ((_product$retailPrice = product === null || product === void 0 ? void 0 : product.retailPrice) != null ? _product$retailPrice : 0) ? /*#__PURE__*/React__default.createElement(DiscountPriceRow$1, {
18825
+ style: getStyleOverride$1(styleOverrides, 'discountPriceRow', 'DiscountPriceRow')
18826
+ }, /*#__PURE__*/React__default.createElement("del", null, "$" + formatPrice$1(product === null || product === void 0 ? void 0 : product.standardPrice)), /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", null, "$" + formatPrice$1(product === null || product === void 0 ? void 0 : product.retailPrice)))) : /*#__PURE__*/React__default.createElement("div", null, "$" + formatPrice$1(product === null || product === void 0 ? void 0 : product.standardPrice))), /*#__PURE__*/React__default.createElement(ProductName$3, {
18827
+ style: getStyleOverride$1(styleOverrides, 'productName', 'ProductName')
18828
+ }, product === null || product === void 0 ? void 0 : product.productName), /*#__PURE__*/React__default.createElement("div", null, (product === null || product === void 0 ? void 0 : product.productStock) > 0 || allowToProcessInvoiceForOutOfStockProducts || product !== null && product !== void 0 && product.hasChildProduct ? /*#__PURE__*/React__default.createElement(ProductActionButton$1, {
18829
+ variant: "contained",
18830
+ color: "primary",
18831
+ primaryColor: primaryColor,
18832
+ style: getStyleOverride$1(styleOverrides, 'productActionButton', 'ProductActionButton'),
18833
+ disabled: moveToCartLoading,
18834
+ onClick: function onClick(e) {
18835
+ try {
18836
+ var _e$stopPropagation2, _e$preventDefault;
18837
+ e === null || e === void 0 ? void 0 : (_e$stopPropagation2 = e.stopPropagation) === null || _e$stopPropagation2 === void 0 ? void 0 : _e$stopPropagation2.call(e);
18838
+ e === null || e === void 0 ? void 0 : (_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
18839
+ if (product !== null && product !== void 0 && product.hasChildProduct) {
18840
+ onProductCardClick === null || onProductCardClick === void 0 ? void 0 : onProductCardClick(product);
18841
+ return Promise.resolve();
18842
+ }
18843
+ var productId = product === null || product === void 0 ? void 0 : product.id;
18844
+ if (productId == null) return Promise.resolve();
18845
+ setMoveToCartLoading(true);
18846
+ var _temp2 = _finallyRethrows(function () {
18847
+ return _catch(function () {
18848
+ return Promise.resolve(moveToCartFromFavoriteItems({
18849
+ apiEndPoint: apiEndPoint,
18850
+ token: token,
18851
+ productId: productId
18852
+ })).then(function () {
18853
+ setRefreshTrigger === null || setRefreshTrigger === void 0 ? void 0 : setRefreshTrigger(function (prev) {
18854
+ return prev + 1;
18855
+ });
18856
+ onMoveToCart === null || onMoveToCart === void 0 ? void 0 : onMoveToCart(product);
18857
+ });
18858
+ }, function () {});
18859
+ }, function (_wasThrown2, _result3) {
18860
+ setMoveToCartLoading(false);
18861
+ if (_wasThrown2) throw _result3;
18862
+ return _result3;
18863
+ });
18864
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
18865
+ } catch (e) {
18866
+ return Promise.reject(e);
18867
+ }
18868
+ }
18869
+ }, product !== null && product !== void 0 && product.hasChildProduct ? 'Select Options' : moveToCartLoading ? 'Moving...' : 'Move to Cart') : /*#__PURE__*/React__default.createElement(OutOfStockButton$1, {
18870
+ variant: "contained",
18871
+ color: "primary",
18872
+ disabled: true,
18873
+ style: getStyleOverride$1(styleOverrides, 'outOfStockButton', 'OutOfStockButton'),
18874
+ onClick: function onClick(e) {
18875
+ var _e$stopPropagation3;
18876
+ return e === null || e === void 0 ? void 0 : (_e$stopPropagation3 = e.stopPropagation) === null || _e$stopPropagation3 === void 0 ? void 0 : _e$stopPropagation3.call(e);
18877
+ }
18878
+ }, "Out Of stock")));
18879
+ };
18880
+
18467
18881
  exports.APIStaticPage = APIStaticPage;
18468
18882
  exports.AccountDetails = AccountDetails;
18469
18883
  exports.BrandList = BrandList;
@@ -18473,6 +18887,7 @@ exports.CartDrawer = CartDrawer;
18473
18887
  exports.CartPageComponent = CartPageComponent;
18474
18888
  exports.CheckoutPageComponent = CheckoutPageComponent;
18475
18889
  exports.ContactUsForm = ContactUsForm;
18890
+ exports.FavoriteItems = FavoriteItemsComponent;
18476
18891
  exports.GTagManager = GTagManager;
18477
18892
  exports.HomeBanner = HomeBanner;
18478
18893
  exports.MaintenancePage = MaintenancePage;