@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.
@@ -97,164 +97,9 @@ function _taggedTemplateLiteralLoose(e, t) {
97
97
  }
98
98
 
99
99
  // A type of promise-like that resolves synchronously and supports only one observer
100
- const _Pact = /*#__PURE__*/(function() {
101
- function _Pact() {}
102
- _Pact.prototype.then = function(onFulfilled, onRejected) {
103
- const result = new _Pact();
104
- const state = this.s;
105
- if (state) {
106
- const callback = state & 1 ? onFulfilled : onRejected;
107
- if (callback) {
108
- try {
109
- _settle(result, 1, callback(this.v));
110
- } catch (e) {
111
- _settle(result, 2, e);
112
- }
113
- return result;
114
- } else {
115
- return this;
116
- }
117
- }
118
- this.o = function(_this) {
119
- try {
120
- const value = _this.v;
121
- if (_this.s & 1) {
122
- _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
123
- } else if (onRejected) {
124
- _settle(result, 1, onRejected(value));
125
- } else {
126
- _settle(result, 2, value);
127
- }
128
- } catch (e) {
129
- _settle(result, 2, e);
130
- }
131
- };
132
- return result;
133
- };
134
- return _Pact;
135
- })();
136
-
137
- // Settles a pact synchronously
138
- function _settle(pact, state, value) {
139
- if (!pact.s) {
140
- if (value instanceof _Pact) {
141
- if (value.s) {
142
- if (state & 1) {
143
- state = value.s;
144
- }
145
- value = value.v;
146
- } else {
147
- value.o = _settle.bind(null, pact, state);
148
- return;
149
- }
150
- }
151
- if (value && value.then) {
152
- value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
153
- return;
154
- }
155
- pact.s = state;
156
- pact.v = value;
157
- const observer = pact.o;
158
- if (observer) {
159
- observer(pact);
160
- }
161
- }
162
- }
163
-
164
- function _isSettledPact(thenable) {
165
- return thenable instanceof _Pact && thenable.s & 1;
166
- }
167
-
168
- // 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)
169
- function _forTo(array, body, check) {
170
- var i = -1, pact, reject;
171
- function _cycle(result) {
172
- try {
173
- while (++i < array.length && (!check || !check())) {
174
- result = body(i);
175
- if (result && result.then) {
176
- if (_isSettledPact(result)) {
177
- result = result.v;
178
- } else {
179
- result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
180
- return;
181
- }
182
- }
183
- }
184
- if (pact) {
185
- _settle(pact, 1, result);
186
- } else {
187
- pact = result;
188
- }
189
- } catch (e) {
190
- _settle(pact || (pact = new _Pact()), 2, e);
191
- }
192
- }
193
- _cycle();
194
- return pact;
195
- }
196
100
 
197
101
  const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator"))) : "@@iterator";
198
102
 
199
- // Asynchronously iterate through an object's values
200
- // Uses for...of if the runtime supports it, otherwise iterates until length on a copy
201
- function _forOf(target, body, check) {
202
- if (typeof target[_iteratorSymbol] === "function") {
203
- var iterator = target[_iteratorSymbol](), step, pact, reject;
204
- function _cycle(result) {
205
- try {
206
- while (!(step = iterator.next()).done && (!check || !check())) {
207
- result = body(step.value);
208
- if (result && result.then) {
209
- if (_isSettledPact(result)) {
210
- result = result.v;
211
- } else {
212
- result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
213
- return;
214
- }
215
- }
216
- }
217
- if (pact) {
218
- _settle(pact, 1, result);
219
- } else {
220
- pact = result;
221
- }
222
- } catch (e) {
223
- _settle(pact || (pact = new _Pact()), 2, e);
224
- }
225
- }
226
- _cycle();
227
- if (iterator.return) {
228
- var _fixup = function(value) {
229
- try {
230
- if (!step.done) {
231
- iterator.return();
232
- }
233
- } catch(e) {
234
- }
235
- return value;
236
- };
237
- if (pact && pact.then) {
238
- return pact.then(_fixup, function(e) {
239
- throw _fixup(e);
240
- });
241
- }
242
- _fixup();
243
- }
244
- return pact;
245
- }
246
- // No support for Symbol.iterator
247
- if (!("length" in target)) {
248
- throw new TypeError("Object is not iterable");
249
- }
250
- // Handle live collections properly
251
- var values = [];
252
- for (var i = 0; i < target.length; i++) {
253
- values.push(target[i]);
254
- }
255
- return _forTo(values, function(i) { return body(values[i]); }, check);
256
- }
257
-
258
103
  const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
259
104
 
260
105
  // Asynchronously call a function and send errors to recovery continuation
@@ -309,7 +154,8 @@ var DATE_FORMATS = {
309
154
  var DEFAULT_PAYMENT_PROVIDER = {
310
155
  BRAIN_TREE: 'braintree',
311
156
  CUSTOM_CREDIT_CARD: 'braintree',
312
- AUTHORISE_DOT_NET: 'authorise-dot-net'
157
+ AUTHORISE_DOT_NET: 'authorise-dot-net',
158
+ NMI: 'nmi'
313
159
  };
314
160
  var CARD_METHODS = {
315
161
  CREDIT_CARD: 2,
@@ -1028,38 +874,67 @@ var getPaymentMethods = function getPaymentMethods(_ref2) {
1028
874
  return Promise.reject(e);
1029
875
  }
1030
876
  };
1031
- var getStoreFeatureDetails = function getStoreFeatureDetails(_ref3) {
1032
- var apiEndPoint = _ref3.apiEndPoint,
1033
- token = _ref3.token;
877
+ var getAuthorizeDotNetCreditCards = function getAuthorizeDotNetCreditCards(_ref4) {
878
+ var apiEndPoint = _ref4.apiEndPoint,
879
+ token = _ref4.token,
880
+ customerId = _ref4.customerId;
1034
881
  try {
1035
882
  return Promise.resolve(API({
1036
883
  apiEndPoint: apiEndPoint,
1037
884
  token: token,
1038
- url: "/store/feature"
885
+ url: "/ecommerce/authoriseDotNet/customerProfile?customerId=" + customerId,
886
+ hideErrorMessage: true
1039
887
  }));
1040
888
  } catch (e) {
1041
889
  return Promise.reject(e);
1042
890
  }
1043
891
  };
1044
- var getAuthorizeDotNetCreditCards = function getAuthorizeDotNetCreditCards(_ref4) {
1045
- var apiEndPoint = _ref4.apiEndPoint,
1046
- token = _ref4.token,
1047
- customerId = _ref4.customerId;
892
+ var getNmiCreditCards = function getNmiCreditCards(_ref5) {
893
+ var apiEndPoint = _ref5.apiEndPoint,
894
+ token = _ref5.token,
895
+ customerId = _ref5.customerId;
1048
896
  try {
1049
897
  return Promise.resolve(API({
1050
898
  apiEndPoint: apiEndPoint,
1051
899
  token: token,
1052
- url: "/ecommerce/authoriseDotNet/customerProfile?customerId=" + customerId,
900
+ url: "/nmi/customers/" + customerId + "/cards",
1053
901
  hideErrorMessage: true
1054
902
  }));
1055
903
  } catch (e) {
1056
904
  return Promise.reject(e);
1057
905
  }
1058
906
  };
1059
- var addAuthoriseDotNetCard = function addAuthoriseDotNetCard(_ref5) {
1060
- var apiEndPoint = _ref5.apiEndPoint,
1061
- token = _ref5.token,
1062
- body = _ref5.body;
907
+ var normalizeSavedCreditCards = function normalizeSavedCreditCards(data) {
908
+ var _data$profile, _cards$;
909
+ if (data !== null && data !== void 0 && (_data$profile = data.profile) !== null && _data$profile !== void 0 && _data$profile.paymentProfiles) return data;
910
+ var cards = Array.isArray(data) ? data : [];
911
+ return {
912
+ profile: {
913
+ customerProfileId: ((_cards$ = cards[0]) === null || _cards$ === void 0 ? void 0 : _cards$.customerProfileId) || null,
914
+ paymentProfiles: cards === null || cards === void 0 ? void 0 : cards.map(function (card) {
915
+ 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;
916
+ return {
917
+ customerPaymentProfileId: card === null || card === void 0 ? void 0 : card.customerPaymentProfileId,
918
+ payment: {
919
+ creditCard: {
920
+ cardType: (card === null || card === void 0 ? void 0 : card.cardName) || 'Card',
921
+ cardNumber: card !== null && card !== void 0 && card.last4 ? "XXXX" + (card === null || card === void 0 ? void 0 : card.last4) : '',
922
+ 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) : '----'
923
+ }
924
+ },
925
+ billTo: {
926
+ 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]) || '',
927
+ 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, ' ')) || ''
928
+ }
929
+ };
930
+ })
931
+ }
932
+ };
933
+ };
934
+ var addAuthoriseDotNetCard = function addAuthoriseDotNetCard(_ref6) {
935
+ var apiEndPoint = _ref6.apiEndPoint,
936
+ token = _ref6.token,
937
+ body = _ref6.body;
1063
938
  try {
1064
939
  return Promise.resolve(API({
1065
940
  apiEndPoint: apiEndPoint,
@@ -1073,9 +948,27 @@ var addAuthoriseDotNetCard = function addAuthoriseDotNetCard(_ref5) {
1073
948
  return Promise.reject(e);
1074
949
  }
1075
950
  };
1076
- var getCartDiscountList = function getCartDiscountList(_ref6) {
1077
- var apiEndPoint = _ref6.apiEndPoint,
1078
- token = _ref6.token;
951
+ var addNmiCard = function addNmiCard(_ref7) {
952
+ var apiEndPoint = _ref7.apiEndPoint,
953
+ token = _ref7.token,
954
+ body = _ref7.body,
955
+ customerId = _ref7.customerId;
956
+ try {
957
+ return Promise.resolve(API({
958
+ apiEndPoint: apiEndPoint,
959
+ token: token,
960
+ url: "/nmi/customers/" + customerId + "/cards",
961
+ method: 'post',
962
+ body: body,
963
+ errorMessage: 'Error in adding card.'
964
+ }));
965
+ } catch (e) {
966
+ return Promise.reject(e);
967
+ }
968
+ };
969
+ var getCartDiscountList = function getCartDiscountList(_ref8) {
970
+ var apiEndPoint = _ref8.apiEndPoint,
971
+ token = _ref8.token;
1079
972
  try {
1080
973
  var storeId = erCookieStorage.getItem('storeId') || 2;
1081
974
  return Promise.resolve(API({
@@ -1088,10 +981,10 @@ var getCartDiscountList = function getCartDiscountList(_ref6) {
1088
981
  return Promise.reject(e);
1089
982
  }
1090
983
  };
1091
- var autoApplyCoupon = function autoApplyCoupon(_ref7) {
1092
- var apiEndPoint = _ref7.apiEndPoint,
1093
- token = _ref7.token,
1094
- subTotal = _ref7.subTotal;
984
+ var autoApplyCoupon = function autoApplyCoupon(_ref9) {
985
+ var apiEndPoint = _ref9.apiEndPoint,
986
+ token = _ref9.token,
987
+ subTotal = _ref9.subTotal;
1095
988
  try {
1096
989
  var storeId = erCookieStorage.getItem('storeId') || 2;
1097
990
  return Promise.resolve(API({
@@ -1108,10 +1001,10 @@ var autoApplyCoupon = function autoApplyCoupon(_ref7) {
1108
1001
  return Promise.reject(e);
1109
1002
  }
1110
1003
  };
1111
- var addCartDiscount = function addCartDiscount(_ref9) {
1112
- var apiEndPoint = _ref9.apiEndPoint,
1113
- token = _ref9.token,
1114
- body = _ref9.body;
1004
+ var addCartDiscount = function addCartDiscount(_ref11) {
1005
+ var apiEndPoint = _ref11.apiEndPoint,
1006
+ token = _ref11.token,
1007
+ body = _ref11.body;
1115
1008
  try {
1116
1009
  var storeId = erCookieStorage.getItem('storeId') || 2;
1117
1010
  return Promise.resolve(API({
@@ -1127,10 +1020,10 @@ var addCartDiscount = function addCartDiscount(_ref9) {
1127
1020
  return Promise.reject(e);
1128
1021
  }
1129
1022
  };
1130
- var deleteCartDiscount = function deleteCartDiscount(_ref10) {
1131
- var apiEndPoint = _ref10.apiEndPoint,
1132
- token = _ref10.token,
1133
- discountId = _ref10.discountId;
1023
+ var deleteCartDiscount = function deleteCartDiscount(_ref12) {
1024
+ var apiEndPoint = _ref12.apiEndPoint,
1025
+ token = _ref12.token,
1026
+ discountId = _ref12.discountId;
1134
1027
  try {
1135
1028
  var storeId = erCookieStorage.getItem('storeId') || 2;
1136
1029
  return Promise.resolve(API({
@@ -1145,10 +1038,10 @@ var deleteCartDiscount = function deleteCartDiscount(_ref10) {
1145
1038
  return Promise.reject(e);
1146
1039
  }
1147
1040
  };
1148
- var addSalesOrder = function addSalesOrder(_ref12) {
1149
- var apiEndPoint = _ref12.apiEndPoint,
1150
- token = _ref12.token,
1151
- orderDetails = _ref12.orderDetails;
1041
+ var addSalesOrder = function addSalesOrder(_ref14) {
1042
+ var apiEndPoint = _ref14.apiEndPoint,
1043
+ token = _ref14.token,
1044
+ orderDetails = _ref14.orderDetails;
1152
1045
  try {
1153
1046
  var storeId = erCookieStorage.getItem('storeId') || 2;
1154
1047
  return Promise.resolve(API({
@@ -1163,10 +1056,10 @@ var addSalesOrder = function addSalesOrder(_ref12) {
1163
1056
  return Promise.reject(e);
1164
1057
  }
1165
1058
  };
1166
- var addQuotation = function addQuotation(_ref13) {
1167
- var apiEndPoint = _ref13.apiEndPoint,
1168
- token = _ref13.token,
1169
- orderDetails = _ref13.orderDetails;
1059
+ var addQuotation = function addQuotation(_ref15) {
1060
+ var apiEndPoint = _ref15.apiEndPoint,
1061
+ token = _ref15.token,
1062
+ orderDetails = _ref15.orderDetails;
1170
1063
  try {
1171
1064
  var storeId = erCookieStorage.getItem('storeId') || 2;
1172
1065
  return Promise.resolve(API({
@@ -1181,9 +1074,9 @@ var addQuotation = function addQuotation(_ref13) {
1181
1074
  return Promise.reject(e);
1182
1075
  }
1183
1076
  };
1184
- var getCustomer = function getCustomer(_ref14) {
1185
- var apiEndPoint = _ref14.apiEndPoint,
1186
- token = _ref14.token;
1077
+ var getCustomer = function getCustomer(_ref16) {
1078
+ var apiEndPoint = _ref16.apiEndPoint,
1079
+ token = _ref16.token;
1187
1080
  try {
1188
1081
  return Promise.resolve(API({
1189
1082
  apiEndPoint: apiEndPoint,
@@ -1195,10 +1088,10 @@ var getCustomer = function getCustomer(_ref14) {
1195
1088
  return Promise.reject(e);
1196
1089
  }
1197
1090
  };
1198
- var getDeliveryOption = function getDeliveryOption(_ref15) {
1199
- var apiEndPoint = _ref15.apiEndPoint,
1200
- token = _ref15.token,
1201
- queryParams = _ref15.queryParams;
1091
+ var getDeliveryOption = function getDeliveryOption(_ref17) {
1092
+ var apiEndPoint = _ref17.apiEndPoint,
1093
+ token = _ref17.token,
1094
+ queryParams = _ref17.queryParams;
1202
1095
  try {
1203
1096
  return Promise.resolve(API({
1204
1097
  apiEndPoint: apiEndPoint,
@@ -1210,10 +1103,10 @@ var getDeliveryOption = function getDeliveryOption(_ref15) {
1210
1103
  return Promise.reject(e);
1211
1104
  }
1212
1105
  };
1213
- var getShipStationDeliveryOption = function getShipStationDeliveryOption(_ref16) {
1214
- var apiEndPoint = _ref16.apiEndPoint,
1215
- token = _ref16.token,
1216
- queryParams = _ref16.queryParams;
1106
+ var getShipStationDeliveryOption = function getShipStationDeliveryOption(_ref18) {
1107
+ var apiEndPoint = _ref18.apiEndPoint,
1108
+ token = _ref18.token,
1109
+ queryParams = _ref18.queryParams;
1217
1110
  try {
1218
1111
  return Promise.resolve(API({
1219
1112
  apiEndPoint: apiEndPoint,
@@ -1225,10 +1118,10 @@ var getShipStationDeliveryOption = function getShipStationDeliveryOption(_ref16)
1225
1118
  return Promise.reject(e);
1226
1119
  }
1227
1120
  };
1228
- var getTaxData = function getTaxData(_ref17) {
1229
- var apiEndPoint = _ref17.apiEndPoint,
1230
- token = _ref17.token,
1231
- shippingAddressId = _ref17.shippingAddressId;
1121
+ var getTaxData = function getTaxData(_ref19) {
1122
+ var apiEndPoint = _ref19.apiEndPoint,
1123
+ token = _ref19.token,
1124
+ shippingAddressId = _ref19.shippingAddressId;
1232
1125
  try {
1233
1126
  var storeId = erCookieStorage.getItem('storeId') || 2;
1234
1127
  return Promise.resolve(API({
@@ -1244,11 +1137,11 @@ var getTaxData = function getTaxData(_ref17) {
1244
1137
  return Promise.reject(e);
1245
1138
  }
1246
1139
  };
1247
- var createStoreAddress = function createStoreAddress(_ref18) {
1248
- var apiEndPoint = _ref18.apiEndPoint,
1249
- token = _ref18.token,
1250
- data = _ref18.data,
1251
- customerId = _ref18.customerId;
1140
+ var createStoreAddress = function createStoreAddress(_ref20) {
1141
+ var apiEndPoint = _ref20.apiEndPoint,
1142
+ token = _ref20.token,
1143
+ data = _ref20.data,
1144
+ customerId = _ref20.customerId;
1252
1145
  try {
1253
1146
  return Promise.resolve(API({
1254
1147
  apiEndPoint: apiEndPoint,
@@ -2321,6 +2214,7 @@ var getCountry = function getCountry(_ref2) {
2321
2214
  var AddAuthorizeDotNetCard = function AddAuthorizeDotNetCard(_ref) {
2322
2215
  var apiEndPoint = _ref.apiEndPoint,
2323
2216
  token = _ref.token,
2217
+ paymentProvider = _ref.paymentProvider,
2324
2218
  visible = _ref.visible,
2325
2219
  onCancel = _ref.onCancel,
2326
2220
  styles = _ref.styles,
@@ -2394,7 +2288,7 @@ var AddAuthorizeDotNetCard = function AddAuthorizeDotNetCard(_ref) {
2394
2288
  };
2395
2289
  var onSubmit = function onSubmit(formData) {
2396
2290
  try {
2397
- var _temp3 = function _temp3() {
2291
+ var _temp6 = function _temp6() {
2398
2292
  setSubmitLoading(false);
2399
2293
  };
2400
2294
  setSubmitLoading(true);
@@ -2404,17 +2298,35 @@ var AddAuthorizeDotNetCard = function AddAuthorizeDotNetCard(_ref) {
2404
2298
  customerId: customerId
2405
2299
  })
2406
2300
  };
2407
- var _temp2 = _catch(function () {
2408
- return Promise.resolve(addAuthoriseDotNetCard({
2409
- apiEndPoint: apiEndPoint,
2410
- token: token,
2411
- body: body
2412
- })).then(function () {
2301
+ var _temp5 = _catch(function () {
2302
+ function _temp4() {
2413
2303
  setListUpdate && setListUpdate(getRandomString());
2414
2304
  onCancel && onCancel();
2415
- });
2305
+ }
2306
+ var _temp3 = function () {
2307
+ if (paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet) {
2308
+ return Promise.resolve(addAuthoriseDotNetCard({
2309
+ apiEndPoint: apiEndPoint,
2310
+ token: token,
2311
+ body: body
2312
+ })).then(function () {});
2313
+ } else {
2314
+ var _temp7 = function () {
2315
+ if (paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.nmi) {
2316
+ return Promise.resolve(addNmiCard({
2317
+ apiEndPoint: apiEndPoint,
2318
+ token: token,
2319
+ body: body === null || body === void 0 ? void 0 : body.customerOrderCard,
2320
+ customerId: customerId
2321
+ })).then(function () {});
2322
+ }
2323
+ }();
2324
+ if (_temp7 && _temp7.then) return _temp7.then(function () {});
2325
+ }
2326
+ }();
2327
+ return _temp3 && _temp3.then ? _temp3.then(_temp4) : _temp4(_temp3);
2416
2328
  }, function () {});
2417
- return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2));
2329
+ return Promise.resolve(_temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5));
2418
2330
  } catch (e) {
2419
2331
  return Promise.reject(e);
2420
2332
  }
@@ -2576,7 +2488,7 @@ var AddAuthorizeDotNetCard = function AddAuthorizeDotNetCard(_ref) {
2576
2488
 
2577
2489
  var _templateObject$9;
2578
2490
  var PaymentModal = function PaymentModal(_ref) {
2579
- 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;
2491
+ 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;
2580
2492
  var apiEndPoint = _ref.apiEndPoint,
2581
2493
  token = _ref.token,
2582
2494
  visible = _ref.visible,
@@ -2584,7 +2496,8 @@ var PaymentModal = function PaymentModal(_ref) {
2584
2496
  styles = _ref.styles,
2585
2497
  orderId = _ref.orderId,
2586
2498
  storeIdList = _ref.storeIdList,
2587
- setTriggerTableData = _ref.setTriggerTableData;
2499
+ setTriggerTableData = _ref.setTriggerTableData,
2500
+ paymentProvider = _ref.paymentProvider;
2588
2501
  var _useState = useState(),
2589
2502
  orderData = _useState[0],
2590
2503
  setOrderData = _useState[1];
@@ -2601,11 +2514,8 @@ var PaymentModal = function PaymentModal(_ref) {
2601
2514
  submitLoading = _useState5[0],
2602
2515
  setSubmitLoading = _useState5[1];
2603
2516
  var _useState6 = useState(),
2604
- defaultPaymentProvider = _useState6[0],
2605
- setDefaultPaymentProvider = _useState6[1];
2606
- var _useState7 = useState(),
2607
- listUpdate = _useState7[0],
2608
- setListUpdate = _useState7[1];
2517
+ listUpdate = _useState6[0],
2518
+ setListUpdate = _useState6[1];
2609
2519
  var _useForm = useForm({
2610
2520
  defaultValues: {
2611
2521
  insertedTimestamp: getLocalTime({
@@ -2618,17 +2528,18 @@ var PaymentModal = function PaymentModal(_ref) {
2618
2528
  control = _useForm.control,
2619
2529
  setValue = _useForm.setValue,
2620
2530
  watch = _useForm.watch;
2621
- var _useState8 = useState([]),
2622
- setPaymentMethods = _useState8[1];
2623
- var _useState9 = useState(),
2624
- customerCreditCards = _useState9[0],
2625
- setCustomerCreditCards = _useState9[1];
2531
+ var _useState7 = useState([]),
2532
+ setPaymentMethods = _useState7[1];
2533
+ var _useState8 = useState(),
2534
+ customerCreditCards = _useState8[0],
2535
+ setCustomerCreditCards = _useState8[1];
2626
2536
  var paymentModeId = watch('paymentModeId');
2627
2537
  var authorizeDotNetCard = watch('authorizeDotNetCard');
2628
2538
  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) {
2629
2539
  return (data === null || data === void 0 ? void 0 : data.customerPaymentProfileId) === authorizeDotNetCard;
2630
2540
  });
2631
2541
  var storeId = erCookieStorage.getItem('storeId') || 2;
2542
+ var hasSavedCardProvider = (paymentProvider === null || paymentProvider === void 0 ? void 0 : paymentProvider.authoriseDotNet) || (paymentProvider === null || paymentProvider === void 0 ? void 0 : paymentProvider.nmi);
2632
2543
  useEffect(function () {
2633
2544
  if (apiEndPoint) {
2634
2545
  (function () {
@@ -2651,12 +2562,6 @@ var PaymentModal = function PaymentModal(_ref) {
2651
2562
  token: token
2652
2563
  })).then(function (data) {
2653
2564
  setPaymentMethods(data);
2654
- return Promise.resolve(getStoreFeatureDetails({
2655
- apiEndPoint: apiEndPoint,
2656
- token: token
2657
- })).then(function (storeDetails) {
2658
- setDefaultPaymentProvider(storeDetails === null || storeDetails === void 0 ? void 0 : storeDetails.defaultPaymentProvider);
2659
- });
2660
2565
  });
2661
2566
  });
2662
2567
  }, function () {});
@@ -2669,19 +2574,23 @@ var PaymentModal = function PaymentModal(_ref) {
2669
2574
  }, [orderId]);
2670
2575
  useEffect(function () {
2671
2576
  var _orderData$orderDto;
2672
- 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) {
2577
+ if (hasSavedCardProvider && orderData !== null && orderData !== void 0 && (_orderData$orderDto = orderData.orderDto) !== null && _orderData$orderDto !== void 0 && _orderData$orderDto.customerId) {
2673
2578
  if (includes(values(CARD_METHODS), paymentModeId)) {
2674
2579
  (function () {
2675
2580
  try {
2676
2581
  setCardLoading(API_STATUSES.LOADING);
2677
2582
  var _temp3 = _catch(function () {
2678
- var _orderData$orderDto2;
2679
- return Promise.resolve(getAuthorizeDotNetCreditCards({
2583
+ var _orderData$orderDto2, _orderData$orderDto3;
2584
+ return Promise.resolve(paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet ? getAuthorizeDotNetCreditCards({
2680
2585
  apiEndPoint: apiEndPoint,
2681
2586
  token: token,
2682
2587
  customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto2 = orderData.orderDto) === null || _orderData$orderDto2 === void 0 ? void 0 : _orderData$orderDto2.customerId
2588
+ }) : getNmiCreditCards({
2589
+ apiEndPoint: apiEndPoint,
2590
+ token: token,
2591
+ customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto3 = orderData.orderDto) === null || _orderData$orderDto3 === void 0 ? void 0 : _orderData$orderDto3.customerId
2683
2592
  })).then(function (data) {
2684
- setCustomerCreditCards(data);
2593
+ setCustomerCreditCards(normalizeSavedCreditCards(data));
2685
2594
  setCardLoading(API_STATUSES.SUCCESS);
2686
2595
  });
2687
2596
  }, function () {
@@ -2694,7 +2603,7 @@ var PaymentModal = function PaymentModal(_ref) {
2694
2603
  })();
2695
2604
  }
2696
2605
  }
2697
- }, [paymentModeId, listUpdate, defaultPaymentProvider]);
2606
+ }, [paymentModeId, listUpdate, paymentProvider, orderData, hasSavedCardProvider]);
2698
2607
  useEffect(function () {
2699
2608
  if (!includes(values(CARD_METHODS), paymentModeId)) {
2700
2609
  setValue('authorizeDotNetCard', null);
@@ -2709,11 +2618,11 @@ var PaymentModal = function PaymentModal(_ref) {
2709
2618
  };
2710
2619
  setSubmitLoading(true);
2711
2620
  var _temp4 = _catch(function () {
2712
- var _orderData$orderDto3, _orderData$orderDto4, _customerCreditCards$3;
2621
+ var _orderData$orderDto4, _orderData$orderDto5, _customerCreditCards$3;
2713
2622
  var modifyData = cloneDeep(omit(_extends({}, formData, {
2714
2623
  status: 'PAID',
2715
- customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto3 = orderData.orderDto) === null || _orderData$orderDto3 === void 0 ? void 0 : _orderData$orderDto3.customerId,
2716
- orderId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto4 = orderData.orderDto) === null || _orderData$orderDto4 === void 0 ? void 0 : _orderData$orderDto4.id,
2624
+ customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto4 = orderData.orderDto) === null || _orderData$orderDto4 === void 0 ? void 0 : _orderData$orderDto4.customerId,
2625
+ orderId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto5 = orderData.orderDto) === null || _orderData$orderDto5 === void 0 ? void 0 : _orderData$orderDto5.id,
2717
2626
  storeId: storeId || 2,
2718
2627
  authorizeDotNetCustomerPaymentProfileId: authorizeDotNetCardData === null || authorizeDotNetCardData === void 0 ? void 0 : authorizeDotNetCardData.customerPaymentProfileId,
2719
2628
  authorizeDotNetCustomerProfileId: customerCreditCards === null || customerCreditCards === void 0 ? void 0 : (_customerCreditCards$3 = customerCreditCards.profile) === null || _customerCreditCards$3 === void 0 ? void 0 : _customerCreditCards$3.customerProfileId
@@ -2738,6 +2647,7 @@ var PaymentModal = function PaymentModal(_ref) {
2738
2647
  };
2739
2648
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, openAddNewCardModal && /*#__PURE__*/React__default.createElement(AddAuthorizeDotNetCard, {
2740
2649
  apiEndPoint: apiEndPoint,
2650
+ paymentProvider: paymentProvider,
2741
2651
  token: token,
2742
2652
  visible: openAddNewCardModal,
2743
2653
  onCancel: function onCancel() {
@@ -2748,7 +2658,7 @@ var PaymentModal = function PaymentModal(_ref) {
2748
2658
  return Promise.reject(e);
2749
2659
  }
2750
2660
  },
2751
- customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto5 = orderData.orderDto) === null || _orderData$orderDto5 === void 0 ? void 0 : _orderData$orderDto5.customerId,
2661
+ customerId: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto6 = orderData.orderDto) === null || _orderData$orderDto6 === void 0 ? void 0 : _orderData$orderDto6.customerId,
2752
2662
  setListUpdate: setListUpdate,
2753
2663
  styles: styles
2754
2664
  }), visible && /*#__PURE__*/React__default.createElement(MuiModal, _extends({
@@ -2778,7 +2688,7 @@ var PaymentModal = function PaymentModal(_ref) {
2778
2688
  },
2779
2689
  loading: submitLoading,
2780
2690
  onClick: handleSubmit(onSubmit),
2781
- disabled: !authorizeDotNetCard || (orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto6 = orderData.orderDto) === null || _orderData$orderDto6 === void 0 ? void 0 : _orderData$orderDto6.dueAmount) <= 0
2691
+ disabled: !authorizeDotNetCard || (orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto7 = orderData.orderDto) === null || _orderData$orderDto7 === void 0 ? void 0 : _orderData$orderDto7.dueAmount) <= 0
2782
2692
  }, "Save")), /*#__PURE__*/React__default.createElement(Grid, {
2783
2693
  item: true
2784
2694
  }, /*#__PURE__*/React__default.createElement(MuiButton, {
@@ -2801,13 +2711,13 @@ var PaymentModal = function PaymentModal(_ref) {
2801
2711
  xs: 12,
2802
2712
  md: 6,
2803
2713
  lg: 3
2804
- }, /*#__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(Grid, {
2714
+ }, /*#__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(Grid, {
2805
2715
  item: true,
2806
2716
  xs: 12,
2807
2717
  md: 6,
2808
2718
  lg: 3
2809
2719
  }, /*#__PURE__*/React__default.createElement("p", null, getLocalTime({
2810
- time: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto8 = orderData.orderDto) === null || _orderData$orderDto8 === void 0 ? void 0 : _orderData$orderDto8.insertedTimestamp
2720
+ time: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto9 = orderData.orderDto) === null || _orderData$orderDto9 === void 0 ? void 0 : _orderData$orderDto9.insertedTimestamp
2811
2721
  }))), /*#__PURE__*/React__default.createElement(Grid, {
2812
2722
  item: true,
2813
2723
  xs: 12,
@@ -2818,7 +2728,7 @@ var PaymentModal = function PaymentModal(_ref) {
2818
2728
  xs: 12,
2819
2729
  md: 6,
2820
2730
  lg: 3
2821
- }, /*#__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(Grid, {
2731
+ }, /*#__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(Grid, {
2822
2732
  container: true,
2823
2733
  spacing: 2
2824
2734
  }, /*#__PURE__*/React__default.createElement(Grid, {
@@ -2833,8 +2743,8 @@ var PaymentModal = function PaymentModal(_ref) {
2833
2743
  disabled: true,
2834
2744
  control: control,
2835
2745
  fontColor: styles === null || styles === void 0 ? void 0 : styles.fontColor,
2836
- max: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto10 = orderData.orderDto) === null || _orderData$orderDto10 === void 0 ? void 0 : _orderData$orderDto10.dueAmount
2837
- })), defaultPaymentProvider === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET && includes(values(CARD_METHODS), paymentModeId) && /*#__PURE__*/React__default.createElement(Grid, {
2746
+ max: orderData === null || orderData === void 0 ? void 0 : (_orderData$orderDto11 = orderData.orderDto) === null || _orderData$orderDto11 === void 0 ? void 0 : _orderData$orderDto11.dueAmount
2747
+ })), hasSavedCardProvider && includes(values(CARD_METHODS), paymentModeId) && /*#__PURE__*/React__default.createElement(Grid, {
2838
2748
  item: true,
2839
2749
  xs: 12
2840
2750
  }, /*#__PURE__*/React__default.createElement(DataLoader, {
@@ -3300,7 +3210,8 @@ var Dashboard = function Dashboard(_ref) {
3300
3210
  hideTotalCardInDashboardSummary = _ref.hideTotalCardInDashboardSummary,
3301
3211
  _ref$showOnlyRecentOr = _ref.showOnlyRecentOrder,
3302
3212
  showOnlyRecentOrder = _ref$showOnlyRecentOr === void 0 ? false : _ref$showOnlyRecentOr,
3303
- hidePayActionButton = _ref.hidePayActionButton;
3213
+ hidePayActionButton = _ref.hidePayActionButton,
3214
+ paymentProvider = _ref.paymentProvider;
3304
3215
  var _useState = useState({}),
3305
3216
  customerData = _useState[0],
3306
3217
  setCustomerData = _useState[1];
@@ -3751,6 +3662,7 @@ var Dashboard = function Dashboard(_ref) {
3751
3662
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, (isPaymentModal === null || isPaymentModal === void 0 ? void 0 : isPaymentModal.open) && /*#__PURE__*/React__default.createElement(PaymentModal, {
3752
3663
  apiEndPoint: apiEndPoint,
3753
3664
  token: token,
3665
+ paymentProvider: paymentProvider,
3754
3666
  storeIdList: storeIdList,
3755
3667
  visible: isPaymentModal === null || isPaymentModal === void 0 ? void 0 : isPaymentModal.open,
3756
3668
  onCancel: function onCancel() {
@@ -6027,9 +5939,12 @@ var AccountDetails = function AccountDetails(_ref) {
6027
5939
  })) === null || _storeData$find === void 0 ? void 0 : _storeData$find.id) || 2),
6028
5940
  defaultStoreId = _useState6[0],
6029
5941
  setDefaultStoreId = _useState6[1];
6030
- var _useState7 = useState(false),
6031
- authoriseDotNet = _useState7[0],
6032
- setAuthoriseDotNet = _useState7[1];
5942
+ var _useState7 = useState({
5943
+ authoriseDotNet: false,
5944
+ nmi: false
5945
+ }),
5946
+ paymentProvider = _useState7[0],
5947
+ setPaymentProvider = _useState7[1];
6033
5948
  var _useState8 = useState({
6034
5949
  primaryColor: primaryColor || '#424242',
6035
5950
  secondaryColor: secondaryColor || '#FFFFFF',
@@ -6096,7 +6011,10 @@ var AccountDetails = function AccountDetails(_ref) {
6096
6011
  apiEndPoint: apiEndPoint,
6097
6012
  token: token
6098
6013
  })).then(function (storeFeature) {
6099
- setAuthoriseDotNet((storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET);
6014
+ setPaymentProvider({
6015
+ authoriseDotNet: (storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET,
6016
+ nmi: (storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.NMI
6017
+ });
6100
6018
  });
6101
6019
  });
6102
6020
  }, function () {});
@@ -6153,7 +6071,8 @@ var AccountDetails = function AccountDetails(_ref) {
6153
6071
  hideDiscountImage: hideDiscountImage,
6154
6072
  imgNotFoundUrl: imgNotFoundUrl,
6155
6073
  hideInvoiceAction: hideInvoiceAction,
6156
- payInvoiceFromDashboard: authoriseDotNet,
6074
+ paymentProvider: paymentProvider,
6075
+ payInvoiceFromDashboard: (paymentProvider === null || paymentProvider === void 0 ? void 0 : paymentProvider.authoriseDotNet) || (paymentProvider === null || paymentProvider === void 0 ? void 0 : paymentProvider.nmi),
6157
6076
  removeSocialLinks: removeSocialLinks,
6158
6077
  hideTotalCardInDashboardSummary: hideTotalCardInDashboardSummary,
6159
6078
  showOnlyRecentOrder: showOnlyRecentOrder,
@@ -6967,9 +6886,11 @@ var MainContainer$2 = styled.div(_templateObject2$i || (_templateObject2$i = _ta
6967
6886
 
6968
6887
  var _templateObject$s, _templateObject2$j, _templateObject3$d, _templateObject4$a, _templateObject5$6, _templateObject6$4, _templateObject7$3, _templateObject8$3, _templateObject9$3;
6969
6888
  var BrandStock = function BrandStock(_ref) {
6970
- var _Object$keys, _Object$keys2, _data$brands;
6889
+ var _data$brands, _Object$keys, _Object$keys2, _data$brands2;
6971
6890
  var storeData = _ref.storeData,
6972
6891
  apiEndPoint = _ref.apiEndPoint,
6892
+ storeIds = _ref.storeIds,
6893
+ storeId = _ref.storeId,
6973
6894
  _ref$colors = _ref.colors,
6974
6895
  colors = _ref$colors === void 0 ? {
6975
6896
  primaryColor: '#424242'
@@ -6977,60 +6898,123 @@ var BrandStock = function BrandStock(_ref) {
6977
6898
  var _useState = useState(_extends({}, storeData)),
6978
6899
  data = _useState[0],
6979
6900
  setData = _useState[1];
6901
+ var _useState2 = useState(false),
6902
+ isLoading = _useState2[0],
6903
+ setIsLoading = _useState2[1];
6904
+ var resolvedStoreIds = storeIds || storeId || erCookieStorage.getItem('storeId') || 2;
6980
6905
  useEffect(function () {
6981
- (function () {
6906
+ setData(function (prev) {
6907
+ return _extends({}, storeData, {
6908
+ brands: prev === null || prev === void 0 ? void 0 : prev.brands
6909
+ });
6910
+ });
6911
+ }, [storeData]);
6912
+ useEffect(function () {
6913
+ var ignore = false;
6914
+ var fetchBrandStock = function fetchBrandStock() {
6982
6915
  try {
6983
- var _temp = _catch(function () {
6984
- return Promise.resolve(API({
6985
- apiEndPoint: apiEndPoint,
6986
- url: "/ecommerce/brand/list?size=9999"
6987
- })).then(function (brandList) {
6988
- setData(_extends({}, data, {
6989
- brands: brandList === null || brandList === void 0 ? void 0 : brandList.content
6990
- }));
6991
- });
6992
- }, function () {});
6993
- return _temp && _temp.then ? _temp.then(function () {}) : void 0;
6994
- } catch (e) {
6995
- Promise.reject(e);
6996
- }
6997
- })();
6998
- }, []);
6999
- var getBrandProducts = useCallback(function (_ref2) {
7000
- var brand = _ref2.brand;
7001
- try {
7002
- var storeId = erCookieStorage.getItem('storeId') || 2;
7003
- return Promise.resolve(_catch(function () {
7004
- var data = [];
7005
- return Promise.resolve(API({
7006
- apiEndPoint: apiEndPoint,
7007
- url: "/ecommerce/product/brand?brandIdList=" + (brand === null || brand === void 0 ? void 0 : brand.id) + "&storeIds=" + storeId + "&size=9999"
7008
- })).then(function (products) {
7009
- function _temp3() {
7010
- return Promise.resolve(Promise.all(updatePromises)).then(function () {
7011
- return data;
7012
- });
7013
- }
7014
- data = products === null || products === void 0 ? void 0 : products.content;
7015
- var updatePromises = [];
7016
- var _temp2 = _forOf(products === null || products === void 0 ? void 0 : products.content, function (product) {
6916
+ setIsLoading(true);
6917
+ return Promise.resolve(_finallyRethrows(function () {
6918
+ return _catch(function () {
7017
6919
  return Promise.resolve(API({
7018
6920
  apiEndPoint: apiEndPoint,
7019
- url: "/ecommerce/product/" + (product === null || product === void 0 ? void 0 : product.productId) + "?storeIds=" + storeId
7020
- })).then(function (childProducts) {
7021
- var _childProducts$body;
7022
- product.childProducts = (childProducts === null || childProducts === void 0 ? void 0 : (_childProducts$body = childProducts.body) === null || _childProducts$body === void 0 ? void 0 : _childProducts$body.content) || [];
6921
+ url: "/ecommerce/product/brandProductStock?storeIds=" + resolvedStoreIds + "&page=0&size=9999"
6922
+ })).then(function (brandList) {
6923
+ if (ignore) {
6924
+ return;
6925
+ }
6926
+ var content = Array.isArray(brandList === null || brandList === void 0 ? void 0 : brandList.content) ? brandList.content : Array.isArray(brandList) ? brandList : [];
6927
+ setData(function (prev) {
6928
+ return _extends({}, prev, {
6929
+ brands: content
6930
+ });
6931
+ });
7023
6932
  });
6933
+ }, function () {
6934
+ if (!ignore) {
6935
+ setData(function (prev) {
6936
+ return _extends({}, prev, {
6937
+ brands: []
6938
+ });
6939
+ });
6940
+ }
7024
6941
  });
7025
- return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
7026
- });
7027
- }, function () {
7028
- return [];
6942
+ }, function (_wasThrown, _result) {
6943
+ if (!ignore) {
6944
+ setIsLoading(false);
6945
+ }
6946
+ if (_wasThrown) throw _result;
6947
+ return _result;
6948
+ }));
6949
+ } catch (e) {
6950
+ return Promise.reject(e);
6951
+ }
6952
+ };
6953
+ fetchBrandStock();
6954
+ return function () {
6955
+ ignore = true;
6956
+ };
6957
+ }, [apiEndPoint, resolvedStoreIds]);
6958
+ 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) {
6959
+ var _brand$brandAttachmen, _brand$brandAttachmen2;
6960
+ var products = brand === null || brand === void 0 ? void 0 : brand.products;
6961
+ return /*#__PURE__*/React__default.createElement("div", {
6962
+ style: {
6963
+ margin: '1.2rem 0'
6964
+ },
6965
+ key: (brand === null || brand === void 0 ? void 0 : brand.id) || i
6966
+ }, /*#__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) {
6967
+ return /*#__PURE__*/React__default.createElement("div", {
6968
+ style: {
6969
+ display: 'flex'
6970
+ },
6971
+ key: i
6972
+ }, /*#__PURE__*/React__default.createElement("img", {
6973
+ className: "brandImage",
6974
+ alt: "logo",
6975
+ src: (brand === null || brand === void 0 ? void 0 : brand.url) || noImgAvailable$1
7029
6976
  }));
7030
- } catch (e) {
7031
- return Promise.reject(e);
7032
- }
7033
- }, []);
6977
+ }), /*#__PURE__*/React__default.createElement("div", {
6978
+ style: {
6979
+ marginBottom: '0.4rem',
6980
+ textAlign: 'center'
6981
+ }
6982
+ }, /*#__PURE__*/React__default.createElement("p", {
6983
+ style: {
6984
+ fontWeight: 600
6985
+ }
6986
+ }, 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, {
6987
+ component: Paper$1
6988
+ }, /*#__PURE__*/React__default.createElement(Table$1, {
6989
+ "aria-label": "simple table",
6990
+ size: "small"
6991
+ }, /*#__PURE__*/React__default.createElement(TableHead$1, null, /*#__PURE__*/React__default.createElement(TableRow$1, null, /*#__PURE__*/React__default.createElement(TableCell$1, null, /*#__PURE__*/React__default.createElement("b", null, "Product Name")), /*#__PURE__*/React__default.createElement(TableCell$1, {
6992
+ align: "right"
6993
+ }, /*#__PURE__*/React__default.createElement("b", null, "Stock")))), /*#__PURE__*/React__default.createElement(TableBody$1, null, (products === null || products === void 0 ? void 0 : products.length) > 0 ? products === null || products === void 0 ? void 0 : products.map(function (product, i) {
6994
+ var _product$childProduct, _product$childProduct2;
6995
+ 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) {
6996
+ return /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
6997
+ key: i,
6998
+ availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
6999
+ }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7000
+ availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7001
+ }, (child === null || child === void 0 ? void 0 : child.productName) || (child === null || child === void 0 ? void 0 : child.name)), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7002
+ align: "right",
7003
+ availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0,
7004
+ stockCol: true
7005
+ }, child.availableQuantity > 0 ? 'In Stock' : 'Out of Stock'));
7006
+ }) : /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7007
+ key: i,
7008
+ availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7009
+ }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7010
+ availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7011
+ }, (product === null || product === void 0 ? void 0 : product.productName) || (product === null || product === void 0 ? void 0 : product.name)), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7012
+ align: "right",
7013
+ availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0,
7014
+ stockCol: true
7015
+ }, (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0 ? 'In Stock' : 'Out of Stock'));
7016
+ }) : /*#__PURE__*/React__default.createElement(TableRow$1, null, /*#__PURE__*/React__default.createElement(TableCell$1, null, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("p", null, "No Data Found"))), /*#__PURE__*/React__default.createElement(TableCell$1, null)))))));
7017
+ });
7034
7018
  return /*#__PURE__*/React__default.createElement(ThemeProvider, {
7035
7019
  theme: colors
7036
7020
  }, /*#__PURE__*/React__default.createElement(Root$9, null, /*#__PURE__*/React__default.createElement(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", {
@@ -7051,74 +7035,9 @@ var BrandStock = function BrandStock(_ref) {
7051
7035
  key: i,
7052
7036
  className: "lineContainer"
7053
7037
  }, /*#__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]));
7054
- }))), /*#__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) {
7055
- return /*#__PURE__*/React__default.createElement("div", {
7056
- style: {
7057
- margin: '1.2rem 0'
7058
- },
7059
- key: i
7060
- }, /*#__PURE__*/React__default.createElement(AsyncDataLoadComponent, {
7061
- apiEndPoint: apiEndPoint,
7062
- asyncService: function asyncService() {
7063
- return getBrandProducts({
7064
- brand: brand
7065
- });
7066
- }
7067
- }, function (products) {
7068
- var _brand$brandAttachmen, _brand$brandAttachmen2;
7069
- 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) {
7070
- return /*#__PURE__*/React__default.createElement("div", {
7071
- style: {
7072
- display: 'flex'
7073
- },
7074
- key: i
7075
- }, /*#__PURE__*/React__default.createElement("img", {
7076
- className: "brandImage",
7077
- alt: "logo",
7078
- src: (brand === null || brand === void 0 ? void 0 : brand.url) || noImgAvailable$1
7079
- }));
7080
- }), /*#__PURE__*/React__default.createElement("div", {
7081
- style: {
7082
- marginBottom: '0.4rem',
7083
- textAlign: 'center'
7084
- }
7085
- }, /*#__PURE__*/React__default.createElement("p", {
7086
- style: {
7087
- fontWeight: 600
7088
- }
7089
- }, 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, {
7090
- component: Paper$1
7091
- }, /*#__PURE__*/React__default.createElement(Table$1, {
7092
- "aria-label": "simple table",
7093
- size: "small"
7094
- }, /*#__PURE__*/React__default.createElement(TableHead$1, null, /*#__PURE__*/React__default.createElement(TableRow$1, null, /*#__PURE__*/React__default.createElement(TableCell$1, null, /*#__PURE__*/React__default.createElement("b", null, "Product Name")), /*#__PURE__*/React__default.createElement(TableCell$1, {
7095
- align: "right"
7096
- }, /*#__PURE__*/React__default.createElement("b", null, "Stock")))), /*#__PURE__*/React__default.createElement(TableBody$1, null, (products === null || products === void 0 ? void 0 : products.length) > 0 ? products === null || products === void 0 ? void 0 : products.map(function (product, i) {
7097
- var _product$childProduct, _product$childProduct2;
7098
- 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) {
7099
- return /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7100
- key: i,
7101
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7102
- }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7103
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7104
- }, child === null || child === void 0 ? void 0 : child.productName), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7105
- align: "right",
7106
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0,
7107
- stockCol: true
7108
- }, child.availableQuantity > 0 ? 'In Stock' : 'Out of Stock'));
7109
- }) : /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7110
- key: i,
7111
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7112
- }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7113
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7114
- }, product === null || product === void 0 ? void 0 : product.productName), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7115
- align: "right",
7116
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0,
7117
- stockCol: true
7118
- }, (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0 ? 'In Stock' : 'Out of Stock'));
7119
- }) : /*#__PURE__*/React__default.createElement(TableRow$1, null, /*#__PURE__*/React__default.createElement(TableCell$1, null, /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("p", null, "No Data Found"))), /*#__PURE__*/React__default.createElement(TableCell$1, null))))));
7120
- }));
7121
- })), (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))));
7038
+ }))), /*#__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, {
7039
+ height: 80
7040
+ }), 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))));
7122
7041
  };
7123
7042
  var Root$9 = styled.div(_templateObject$s || (_templateObject$s = _taggedTemplateLiteralLoose(["\n padding: 1rem;\n"])));
7124
7043
  var TitleContainer$1 = styled.div(_templateObject2$j || (_templateObject2$j = _taggedTemplateLiteralLoose(["\n padding: 0 1rem;\n display: flex;\n justify-content: space-between;\n"])));
@@ -14619,7 +14538,7 @@ var Step3 = function Step3(_ref) {
14619
14538
  var _customer$customerDto, _selectedMethod$name, _styles$button2;
14620
14539
  var apiEndPoint = _ref.apiEndPoint,
14621
14540
  token = _ref.token,
14622
- authoriseDotNet = _ref.authoriseDotNet,
14541
+ paymentProvider = _ref.paymentProvider,
14623
14542
  handleBack = _ref.handleBack,
14624
14543
  _handleNext = _ref.handleNext,
14625
14544
  setPaymentDetails = _ref.setPaymentDetails,
@@ -14650,7 +14569,7 @@ var Step3 = function Step3(_ref) {
14650
14569
  var _useState5 = useState(),
14651
14570
  selectCardValue = _useState5[0],
14652
14571
  setSelectCardValue = _useState5[1];
14653
- var _useState6 = useState(authoriseDotNet ? true : false),
14572
+ var _useState6 = useState(paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet || paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.nmi ? true : false),
14654
14573
  addNewCard = _useState6[0],
14655
14574
  setAddNewCard = _useState6[1];
14656
14575
  var _useState7 = useState(false),
@@ -14668,13 +14587,17 @@ var Step3 = function Step3(_ref) {
14668
14587
  try {
14669
14588
  return _catch(function () {
14670
14589
  var _temp = function () {
14671
- if (customerId && apiEndPoint && token && authoriseDotNet) {
14672
- return Promise.resolve(getAuthorizeDotNetCreditCards({
14590
+ if (customerId && apiEndPoint && token && (paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet || paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.nmi)) {
14591
+ return Promise.resolve(paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet ? getAuthorizeDotNetCreditCards({
14592
+ apiEndPoint: apiEndPoint,
14593
+ token: token,
14594
+ customerId: customerId
14595
+ }) : getNmiCreditCards({
14673
14596
  apiEndPoint: apiEndPoint,
14674
14597
  token: token,
14675
14598
  customerId: customerId
14676
14599
  })).then(function (data) {
14677
- setCreditCardListData(data);
14600
+ setCreditCardListData(normalizeSavedCreditCards(data));
14678
14601
  });
14679
14602
  }
14680
14603
  }();
@@ -15626,9 +15549,12 @@ var CheckoutPageComponentWrapper = function CheckoutPageComponentWrapper(_ref) {
15626
15549
  var _useState4 = useState(0),
15627
15550
  currStep = _useState4[0],
15628
15551
  setCurrStep = _useState4[1];
15629
- var _useState5 = useState(false),
15630
- authoriseDotNet = _useState5[0],
15631
- setAuthoriseDotNet = _useState5[1];
15552
+ var _useState5 = useState({
15553
+ authoriseDotNet: false,
15554
+ nmi: false
15555
+ }),
15556
+ paymentProvider = _useState5[0],
15557
+ setPaymentProvider = _useState5[1];
15632
15558
  var _useState6 = useState([]),
15633
15559
  deliveryOptions = _useState6[0],
15634
15560
  setDeliveryOptions = _useState6[1];
@@ -15706,7 +15632,10 @@ var CheckoutPageComponentWrapper = function CheckoutPageComponentWrapper(_ref) {
15706
15632
  apiEndPoint: apiEndPoint,
15707
15633
  token: token
15708
15634
  })).then(function (storeFeature) {
15709
- setAuthoriseDotNet((storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET);
15635
+ setPaymentProvider({
15636
+ authoriseDotNet: (storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.AUTHORISE_DOT_NET,
15637
+ nmi: (storeFeature === null || storeFeature === void 0 ? void 0 : storeFeature.defaultPaymentProvider) === DEFAULT_PAYMENT_PROVIDER.NMI
15638
+ });
15710
15639
  });
15711
15640
  });
15712
15641
  }, function () {});
@@ -16129,7 +16058,7 @@ var CheckoutPageComponentWrapper = function CheckoutPageComponentWrapper(_ref) {
16129
16058
  var orderPaymentList;
16130
16059
  var ecommerceCustomPaymentDto = null;
16131
16060
  if (card) {
16132
- var cardData = authoriseDotNet ? {
16061
+ var cardData = paymentProvider !== null && paymentProvider !== void 0 && paymentProvider.authoriseDotNet ? {
16133
16062
  firstName: card === null || card === void 0 ? void 0 : card.firstName,
16134
16063
  lastName: card === null || card === void 0 ? void 0 : card.lastName
16135
16064
  } : {
@@ -16346,7 +16275,7 @@ var CheckoutPageComponentWrapper = function CheckoutPageComponentWrapper(_ref) {
16346
16275
  }, /*#__PURE__*/React__default.createElement(Step3, {
16347
16276
  customer: customer,
16348
16277
  apiEndPoint: apiEndPoint,
16349
- authoriseDotNet: authoriseDotNet,
16278
+ paymentProvider: paymentProvider,
16350
16279
  token: token,
16351
16280
  currstep: currStep,
16352
16281
  handleBack: handleBack,
@@ -18460,5 +18389,490 @@ var ProductCard = function ProductCard(_ref4) {
18460
18389
  }, "Out Of stock")));
18461
18390
  };
18462
18391
 
18463
- export { APIStaticPage, AccountDetails, BrandList, BrandStock, Breakpoint, CartDrawer, CartPageComponent, CheckoutPageComponent, ContactUsForm, GTagManager, HomeBanner, MaintenancePage, NewArrivalPage, OutOfStock, QuickOrder, RenderTawk, SingleBanner, SnowfallComponent as Snowfall, StaticPage, StaticPageList, SwitchUser, ThankYou, Variant, VendorAccountDetails as VendorAccount, WishlistComponent as Wishlist, useGridSize, useWindowSize };
18392
+ var cardStyle$1 = {
18393
+ border: '1px solid #d3d3d3',
18394
+ borderRadius: '10px',
18395
+ display: 'flex',
18396
+ flexDirection: 'column',
18397
+ justifyContent: 'center',
18398
+ alignItems: 'center',
18399
+ padding: '10px',
18400
+ gap: '10px',
18401
+ backgroundColor: '#ffffff'
18402
+ };
18403
+ var FavoriteItemsProductCardSkeleton = function FavoriteItemsProductCardSkeleton(_ref) {
18404
+ var span = _ref.span,
18405
+ _ref$count = _ref.count,
18406
+ count = _ref$count === void 0 ? 18 : _ref$count;
18407
+ return /*#__PURE__*/React__default.createElement(Grid, {
18408
+ container: true,
18409
+ spacing: 2
18410
+ }, Array.from({
18411
+ length: count
18412
+ }).map(function (_, i) {
18413
+ var _span$xs, _span$sm, _span$md, _span$lg;
18414
+ return /*#__PURE__*/React__default.createElement(Grid, {
18415
+ item: true,
18416
+ xs: (_span$xs = span === null || span === void 0 ? void 0 : span.xs) != null ? _span$xs : 12,
18417
+ sm: (_span$sm = span === null || span === void 0 ? void 0 : span.sm) != null ? _span$sm : 6,
18418
+ md: (_span$md = span === null || span === void 0 ? void 0 : span.md) != null ? _span$md : 4,
18419
+ lg: (_span$lg = span === null || span === void 0 ? void 0 : span.lg) != null ? _span$lg : 2,
18420
+ key: i
18421
+ }, /*#__PURE__*/React__default.createElement("div", {
18422
+ style: cardStyle$1
18423
+ }, /*#__PURE__*/React__default.createElement(Skeleton$1, {
18424
+ variant: "rectangular",
18425
+ width: 160,
18426
+ height: 160,
18427
+ animation: "wave"
18428
+ }), /*#__PURE__*/React__default.createElement(Skeleton$1, {
18429
+ variant: "text",
18430
+ width: 80,
18431
+ height: 24,
18432
+ animation: "wave"
18433
+ }), /*#__PURE__*/React__default.createElement(Skeleton$1, {
18434
+ variant: "text",
18435
+ width: "90%",
18436
+ height: 43,
18437
+ animation: "wave"
18438
+ }), /*#__PURE__*/React__default.createElement(Skeleton$1, {
18439
+ variant: "rectangular",
18440
+ width: 120,
18441
+ height: 36,
18442
+ animation: "wave",
18443
+ sx: {
18444
+ borderRadius: '10px'
18445
+ }
18446
+ })));
18447
+ }));
18448
+ };
18449
+
18450
+ var getFavoriteItemsData = function getFavoriteItemsData(_ref) {
18451
+ var apiEndPoint = _ref.apiEndPoint,
18452
+ token = _ref.token,
18453
+ _ref$queryParams = _ref.queryParams,
18454
+ queryParams = _ref$queryParams === void 0 ? {} : _ref$queryParams;
18455
+ try {
18456
+ if (!apiEndPoint || !token) return Promise.resolve([]);
18457
+ return Promise.resolve(API({
18458
+ apiEndPoint: apiEndPoint,
18459
+ token: token,
18460
+ url: "/ecommerce/favoriteProduct",
18461
+ queryParams: queryParams
18462
+ })).then(function (data) {
18463
+ return data != null ? data : [];
18464
+ });
18465
+ } catch (e) {
18466
+ return Promise.reject(e);
18467
+ }
18468
+ };
18469
+ var removeFromFavoriteItems = function removeFromFavoriteItems(_ref2) {
18470
+ var apiEndPoint = _ref2.apiEndPoint,
18471
+ token = _ref2.token,
18472
+ productId = _ref2.productId;
18473
+ try {
18474
+ var _erCookieStorage$getI;
18475
+ if (!apiEndPoint || !token || productId == null) return Promise.resolve();
18476
+ 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;
18477
+ return Promise.resolve(API({
18478
+ apiEndPoint: apiEndPoint,
18479
+ token: token,
18480
+ url: "/ecommerce/favoriteProduct",
18481
+ method: 'delete',
18482
+ queryParams: {
18483
+ productId: productId,
18484
+ storeId: storeId
18485
+ },
18486
+ successMessage: 'Product removed from favorites successfully',
18487
+ errorMessage: 'Error in removing product from favorites'
18488
+ })).then(function () {});
18489
+ } catch (e) {
18490
+ return Promise.reject(e);
18491
+ }
18492
+ };
18493
+ var moveToCartFromFavoriteItems = function moveToCartFromFavoriteItems(_ref3) {
18494
+ var apiEndPoint = _ref3.apiEndPoint,
18495
+ token = _ref3.token,
18496
+ productId = _ref3.productId;
18497
+ try {
18498
+ if (!apiEndPoint || !token || productId == null) return Promise.resolve();
18499
+ return Promise.resolve(API({
18500
+ apiEndPoint: apiEndPoint,
18501
+ token: token,
18502
+ url: "/ecommerce/favoriteProduct/move-to-cart",
18503
+ method: 'post',
18504
+ body: [productId],
18505
+ successMessage: 'Product moved to cart successfully',
18506
+ errorMessage: 'Error in moving product to cart'
18507
+ })).then(function () {});
18508
+ } catch (e) {
18509
+ return Promise.reject(e);
18510
+ }
18511
+ };
18512
+
18513
+ var _templateObject$Y, _templateObject2$G, _templateObject3$w, _templateObject4$q, _templateObject5$l, _templateObject6$j, _templateObject7$f, _templateObject8$d, _templateObject9$9, _templateObject10$7, _templateObject11$6;
18514
+ var EmptyStateText$1 = styled.p(_templateObject$Y || (_templateObject$Y = _taggedTemplateLiteralLoose(["\n font-size: 16px;\n color: #4b4b4b;\n margin: 16px 0;\n"])));
18515
+ var ProductCardWrapper$1 = styled.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"])));
18516
+ var TopBar$1 = styled.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"])));
18517
+ var SearchWrapper$1 = styled(Box)(_templateObject4$q || (_templateObject4$q = _taggedTemplateLiteralLoose(["\n && {\n margin-bottom: 24px;\n max-width: 400px;\n width: 100%;\n }\n"])));
18518
+ var TotalItemsText$1 = styled.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"])));
18519
+ var DeleteButton$1 = styled.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"])));
18520
+ var PriceContainer$1 = styled.div(_templateObject7$f || (_templateObject7$f = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n"])));
18521
+ var DiscountPriceRow$1 = styled.div(_templateObject8$d || (_templateObject8$d = _taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n"])));
18522
+ var ProductName$3 = styled.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"])));
18523
+ var ProductActionButton$1 = styled(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) {
18524
+ var primaryColor = _ref.primaryColor;
18525
+ return primaryColor != null ? primaryColor : '#000000';
18526
+ });
18527
+ var OutOfStockButton$1 = styled(Button)(_templateObject11$6 || (_templateObject11$6 = _taggedTemplateLiteralLoose(["\n && {\n color: #ffffff;\n border-radius: 10px;\n font-weight: 500;\n }\n"])));
18528
+
18529
+ var getProductImage$1 = function getProductImage(imageUrl, fallbackUrl) {
18530
+ var url = imageUrl || fallbackUrl;
18531
+ return url && url !== 'null' ? url : '/images/products/imgnotfound.png';
18532
+ };
18533
+ var formatPrice$1 = function formatPrice(price) {
18534
+ var value = Number(price);
18535
+ return Number.isFinite(value) ? value.toFixed(2) : '0.00';
18536
+ };
18537
+ var DEFAULT_GRID_SPAN$1 = {
18538
+ lg: 3,
18539
+ md: 4,
18540
+ sm: 6,
18541
+ xs: 6
18542
+ };
18543
+ var getStyleOverride$1 = function getStyleOverride(styleOverrides) {
18544
+ for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
18545
+ keys[_key - 1] = arguments[_key];
18546
+ }
18547
+ for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
18548
+ var key = _keys[_i];
18549
+ if (styleOverrides !== null && styleOverrides !== void 0 && styleOverrides[key]) return styleOverrides[key];
18550
+ }
18551
+ return undefined;
18552
+ };
18553
+ var normalizeFavoriteItems = function normalizeFavoriteItems(data) {
18554
+ if (Array.isArray(data)) return data.filter(Boolean);
18555
+ var content = data === null || data === void 0 ? void 0 : data.content;
18556
+ return Array.isArray(content) ? content.filter(Boolean) : [];
18557
+ };
18558
+ var getFavoriteItemsTotal = function getFavoriteItemsTotal(data, items) {
18559
+ var _items$length;
18560
+ if (typeof (data === null || data === void 0 ? void 0 : data.totalElements) === 'number') {
18561
+ return data === null || data === void 0 ? void 0 : data.totalElements;
18562
+ }
18563
+ return (_items$length = items === null || items === void 0 ? void 0 : items.length) != null ? _items$length : 0;
18564
+ };
18565
+ var FavoriteItemsContent = function FavoriteItemsContent(_ref) {
18566
+ var data = _ref.data,
18567
+ apiEndPoint = _ref.apiEndPoint,
18568
+ token = _ref.token,
18569
+ searchInput = _ref.searchInput,
18570
+ onSearchChange = _ref.onSearchChange,
18571
+ styleOverrides = _ref.styleOverrides,
18572
+ gridSpan = _ref.gridSpan,
18573
+ primaryColor = _ref.primaryColor,
18574
+ onMoveToCart = _ref.onMoveToCart,
18575
+ onProductCardClick = _ref.onProductCardClick,
18576
+ _ref$imgNotFoundUrl = _ref.imgNotFoundUrl,
18577
+ imgNotFoundUrl = _ref$imgNotFoundUrl === void 0 ? '' : _ref$imgNotFoundUrl,
18578
+ setRefreshTrigger = _ref.setRefreshTrigger,
18579
+ allowToProcessInvoiceForOutOfStockProducts = _ref.allowToProcessInvoiceForOutOfStockProducts;
18580
+ var items = useMemo(function () {
18581
+ return normalizeFavoriteItems(data);
18582
+ }, [data]);
18583
+ var totalItems = useMemo(function () {
18584
+ return getFavoriteItemsTotal(data, items);
18585
+ }, [data, items]);
18586
+ return /*#__PURE__*/React__default.createElement("div", {
18587
+ style: {
18588
+ width: '100%',
18589
+ height: '100%'
18590
+ }
18591
+ }, /*#__PURE__*/React__default.createElement(TopBar$1, {
18592
+ style: getStyleOverride$1(styleOverrides, 'topBar', 'TopBar')
18593
+ }, /*#__PURE__*/React__default.createElement(SearchWrapper$1, {
18594
+ style: getStyleOverride$1(styleOverrides, 'searchWrapper', 'SearchWrapper')
18595
+ }, /*#__PURE__*/React__default.createElement(TextField, {
18596
+ placeholder: "Type minimum 3 characters to search...",
18597
+ value: searchInput,
18598
+ onChange: onSearchChange,
18599
+ size: "small",
18600
+ fullWidth: true,
18601
+ sx: {
18602
+ '& .MuiOutlinedInput-root': {
18603
+ borderRadius: '8px'
18604
+ }
18605
+ }
18606
+ })), /*#__PURE__*/React__default.createElement(TotalItemsText$1, {
18607
+ style: getStyleOverride$1(styleOverrides, 'totalItemsText', 'TotalItemsText')
18608
+ }, "Total " + totalItems + " item" + (totalItems === 1 ? '' : 's'))), !(items !== null && items !== void 0 && items.length) ? /*#__PURE__*/React__default.createElement(EmptyStateText$1, {
18609
+ style: getStyleOverride$1(styleOverrides, 'emptyStateText', 'EmptyStateText')
18610
+ }, "No favorite items found") : /*#__PURE__*/React__default.createElement(Grid, {
18611
+ container: true,
18612
+ spacing: 2
18613
+ }, items === null || items === void 0 ? void 0 : items.map(function (product, index) {
18614
+ var _ref2, _product$id;
18615
+ return /*#__PURE__*/React__default.createElement(Grid, {
18616
+ item: true,
18617
+ xs: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.xs,
18618
+ sm: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.sm,
18619
+ md: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.md,
18620
+ lg: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.lg,
18621
+ 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
18622
+ }, /*#__PURE__*/React__default.createElement(ProductCard$1, {
18623
+ setRefreshTrigger: setRefreshTrigger,
18624
+ apiEndPoint: apiEndPoint,
18625
+ token: token,
18626
+ product: product,
18627
+ styleOverrides: styleOverrides,
18628
+ primaryColor: primaryColor,
18629
+ onMoveToCart: onMoveToCart,
18630
+ onProductCardClick: onProductCardClick,
18631
+ imgNotFoundUrl: imgNotFoundUrl,
18632
+ allowToProcessInvoiceForOutOfStockProducts: allowToProcessInvoiceForOutOfStockProducts
18633
+ }));
18634
+ })));
18635
+ };
18636
+ var FavoriteItemsComponent = function FavoriteItemsComponent(_ref3) {
18637
+ var _ref3$style = _ref3.style,
18638
+ style = _ref3$style === void 0 ? {} : _ref3$style,
18639
+ token = _ref3.token,
18640
+ _ref3$span = _ref3.span,
18641
+ span = _ref3$span === void 0 ? DEFAULT_GRID_SPAN$1 : _ref3$span,
18642
+ primaryColor = _ref3.primaryColor,
18643
+ apiEndPoint = _ref3.apiEndPoint,
18644
+ onMoveToCart = _ref3.onMoveToCart,
18645
+ onProductCardClick = _ref3.onProductCardClick,
18646
+ _ref3$allowToProcessI = _ref3.allowToProcessInvoiceForOutOfStockProducts,
18647
+ allowToProcessInvoiceForOutOfStockProducts = _ref3$allowToProcessI === void 0 ? false : _ref3$allowToProcessI;
18648
+ var styleOverrides = useMemo(function () {
18649
+ return _extends({}, style || {});
18650
+ }, [style]);
18651
+ var _useState = useState(''),
18652
+ searchInput = _useState[0],
18653
+ setSearchInput = _useState[1];
18654
+ var _useState2 = useState(''),
18655
+ searchQuery = _useState2[0],
18656
+ setSearchQuery = _useState2[1];
18657
+ var _useState3 = useState(0),
18658
+ refreshTrigger = _useState3[0],
18659
+ setRefreshTrigger = _useState3[1];
18660
+ var gridSpan = useMemo(function () {
18661
+ return _extends({}, DEFAULT_GRID_SPAN$1, span || {});
18662
+ }, [span]);
18663
+ var debouncedSearch = useMemo(function () {
18664
+ return debounce$1(function (value) {
18665
+ var normalizedValue = value != null ? value : '';
18666
+ if ((normalizedValue === null || normalizedValue === void 0 ? void 0 : normalizedValue.length) === 0 || (normalizedValue === null || normalizedValue === void 0 ? void 0 : normalizedValue.length) >= 3) {
18667
+ setSearchQuery(normalizedValue);
18668
+ }
18669
+ }, 500);
18670
+ }, []);
18671
+ useEffect(function () {
18672
+ return function () {
18673
+ var _debouncedSearch$canc;
18674
+ debouncedSearch === null || debouncedSearch === void 0 ? void 0 : (_debouncedSearch$canc = debouncedSearch.cancel) === null || _debouncedSearch$canc === void 0 ? void 0 : _debouncedSearch$canc.call(debouncedSearch);
18675
+ };
18676
+ }, [debouncedSearch]);
18677
+ var handleSearchChange = useCallback(function (e) {
18678
+ var _e$target$value, _e$target;
18679
+ 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 : '';
18680
+ setSearchInput(value);
18681
+ debouncedSearch(value);
18682
+ }, [debouncedSearch]);
18683
+ var favoriteItemsTrigger = useMemo(function () {
18684
+ return searchQuery + "-" + refreshTrigger;
18685
+ }, [searchQuery, refreshTrigger]);
18686
+ var favoriteItemsAsyncService = useCallback(function () {
18687
+ return getFavoriteItemsData({
18688
+ apiEndPoint: apiEndPoint,
18689
+ token: token,
18690
+ queryParams: _extends({
18691
+ page: 0,
18692
+ size: 9999
18693
+ }, searchQuery ? {
18694
+ productName: searchQuery
18695
+ } : {})
18696
+ });
18697
+ }, [apiEndPoint, token, searchQuery]);
18698
+ var favoriteItemsLoadingView = useMemo(function () {
18699
+ return /*#__PURE__*/React__default.createElement(FavoriteItemsProductCardSkeleton, {
18700
+ span: span
18701
+ });
18702
+ }, [span]);
18703
+ if (!token) {
18704
+ 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."));
18705
+ }
18706
+ if (!apiEndPoint) {
18707
+ return /*#__PURE__*/React__default.createElement(EmptyStateText$1, null, "Unable to load favorite items. API endpoint is not configured.");
18708
+ }
18709
+ return /*#__PURE__*/React__default.createElement("div", {
18710
+ style: {
18711
+ marginTop: '1rem',
18712
+ height: '100%',
18713
+ width: '100%'
18714
+ }
18715
+ }, /*#__PURE__*/React__default.createElement(AsyncDataLoadComponent, {
18716
+ asyncService: favoriteItemsAsyncService,
18717
+ triggerChange: favoriteItemsTrigger,
18718
+ loadingView: favoriteItemsLoadingView
18719
+ }, function (data) {
18720
+ return /*#__PURE__*/React__default.createElement(FavoriteItemsContent, {
18721
+ data: data,
18722
+ apiEndPoint: apiEndPoint,
18723
+ token: token,
18724
+ searchInput: searchInput,
18725
+ onSearchChange: handleSearchChange,
18726
+ styleOverrides: styleOverrides,
18727
+ gridSpan: gridSpan,
18728
+ primaryColor: primaryColor,
18729
+ onMoveToCart: onMoveToCart,
18730
+ onProductCardClick: onProductCardClick,
18731
+ setRefreshTrigger: setRefreshTrigger,
18732
+ allowToProcessInvoiceForOutOfStockProducts: allowToProcessInvoiceForOutOfStockProducts
18733
+ });
18734
+ }));
18735
+ };
18736
+ var ProductCard$1 = function ProductCard(_ref4) {
18737
+ var _product$standardPric, _product$retailPrice;
18738
+ var product = _ref4.product,
18739
+ styleOverrides = _ref4.styleOverrides,
18740
+ primaryColor = _ref4.primaryColor,
18741
+ onMoveToCart = _ref4.onMoveToCart,
18742
+ onProductCardClick = _ref4.onProductCardClick,
18743
+ _ref4$imgNotFoundUrl = _ref4.imgNotFoundUrl,
18744
+ imgNotFoundUrl = _ref4$imgNotFoundUrl === void 0 ? '' : _ref4$imgNotFoundUrl,
18745
+ apiEndPoint = _ref4.apiEndPoint,
18746
+ token = _ref4.token,
18747
+ setRefreshTrigger = _ref4.setRefreshTrigger,
18748
+ allowToProcessInvoiceForOutOfStockProducts = _ref4.allowToProcessInvoiceForOutOfStockProducts;
18749
+ var _useState4 = useState(false),
18750
+ deleteLoading = _useState4[0],
18751
+ setDeleteLoading = _useState4[1];
18752
+ var _useState5 = useState(false),
18753
+ moveToCartLoading = _useState5[0],
18754
+ setMoveToCartLoading = _useState5[1];
18755
+ if (!product) return null;
18756
+ var removeItem = function removeItem(item) {
18757
+ try {
18758
+ if ((item === null || item === void 0 ? void 0 : item.productId) == null) return Promise.resolve();
18759
+ setDeleteLoading(true);
18760
+ var _temp = _finallyRethrows(function () {
18761
+ return _catch(function () {
18762
+ return Promise.resolve(removeFromFavoriteItems({
18763
+ apiEndPoint: apiEndPoint,
18764
+ token: token,
18765
+ productId: item === null || item === void 0 ? void 0 : item.productId
18766
+ })).then(function () {
18767
+ setRefreshTrigger === null || setRefreshTrigger === void 0 ? void 0 : setRefreshTrigger(function (prev) {
18768
+ return prev + 1;
18769
+ });
18770
+ });
18771
+ }, function () {});
18772
+ }, function (_wasThrown, _result) {
18773
+ setDeleteLoading(false);
18774
+ if (_wasThrown) throw _result;
18775
+ return _result;
18776
+ });
18777
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
18778
+ } catch (e) {
18779
+ return Promise.reject(e);
18780
+ }
18781
+ };
18782
+ return /*#__PURE__*/React__default.createElement(ProductCardWrapper$1, {
18783
+ style: getStyleOverride$1(styleOverrides, 'productCardWrapper', 'ProductCardWrapper'),
18784
+ onClick: function onClick() {
18785
+ onProductCardClick === null || onProductCardClick === void 0 ? void 0 : onProductCardClick(product);
18786
+ }
18787
+ }, /*#__PURE__*/React__default.createElement(DeleteButton$1, {
18788
+ type: "button",
18789
+ className: "favorite-items-delete-btn",
18790
+ "aria-label": "Remove from favorites",
18791
+ style: getStyleOverride$1(styleOverrides, 'deleteButton', 'DeleteButton'),
18792
+ onClick: function onClick(e) {
18793
+ try {
18794
+ var _e$stopPropagation;
18795
+ e === null || e === void 0 ? void 0 : (_e$stopPropagation = e.stopPropagation) === null || _e$stopPropagation === void 0 ? void 0 : _e$stopPropagation.call(e);
18796
+ return Promise.resolve(_catch(function () {
18797
+ var _window, _window$confirm;
18798
+ 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?');
18799
+ if (!confirm) return;
18800
+ return Promise.resolve(removeItem(product)).then(function () {});
18801
+ }, function () {}));
18802
+ } catch (e) {
18803
+ return Promise.reject(e);
18804
+ }
18805
+ }
18806
+ }, deleteLoading ? /*#__PURE__*/React__default.createElement(CircularProgress, {
18807
+ size: 20
18808
+ }) : /*#__PURE__*/React__default.createElement(AiOutlineDelete, {
18809
+ style: {
18810
+ fontSize: 18
18811
+ }
18812
+ })), /*#__PURE__*/React__default.createElement(Image$3, {
18813
+ src: getProductImage$1(product === null || product === void 0 ? void 0 : product.imageUrl, imgNotFoundUrl),
18814
+ alt: (product === null || product === void 0 ? void 0 : product.productName) || 'Product',
18815
+ width: 160,
18816
+ height: 160,
18817
+ objectFit: "contain"
18818
+ }), /*#__PURE__*/React__default.createElement(PriceContainer$1, {
18819
+ style: getStyleOverride$1(styleOverrides, 'priceContainer', 'PriceContainer')
18820
+ }, ((_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, {
18821
+ style: getStyleOverride$1(styleOverrides, 'discountPriceRow', 'DiscountPriceRow')
18822
+ }, /*#__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, {
18823
+ style: getStyleOverride$1(styleOverrides, 'productName', 'ProductName')
18824
+ }, 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, {
18825
+ variant: "contained",
18826
+ color: "primary",
18827
+ primaryColor: primaryColor,
18828
+ style: getStyleOverride$1(styleOverrides, 'productActionButton', 'ProductActionButton'),
18829
+ disabled: moveToCartLoading,
18830
+ onClick: function onClick(e) {
18831
+ try {
18832
+ var _e$stopPropagation2, _e$preventDefault;
18833
+ e === null || e === void 0 ? void 0 : (_e$stopPropagation2 = e.stopPropagation) === null || _e$stopPropagation2 === void 0 ? void 0 : _e$stopPropagation2.call(e);
18834
+ e === null || e === void 0 ? void 0 : (_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
18835
+ if (product !== null && product !== void 0 && product.hasChildProduct) {
18836
+ onProductCardClick === null || onProductCardClick === void 0 ? void 0 : onProductCardClick(product);
18837
+ return Promise.resolve();
18838
+ }
18839
+ var productId = product === null || product === void 0 ? void 0 : product.id;
18840
+ if (productId == null) return Promise.resolve();
18841
+ setMoveToCartLoading(true);
18842
+ var _temp2 = _finallyRethrows(function () {
18843
+ return _catch(function () {
18844
+ return Promise.resolve(moveToCartFromFavoriteItems({
18845
+ apiEndPoint: apiEndPoint,
18846
+ token: token,
18847
+ productId: productId
18848
+ })).then(function () {
18849
+ setRefreshTrigger === null || setRefreshTrigger === void 0 ? void 0 : setRefreshTrigger(function (prev) {
18850
+ return prev + 1;
18851
+ });
18852
+ onMoveToCart === null || onMoveToCart === void 0 ? void 0 : onMoveToCart(product);
18853
+ });
18854
+ }, function () {});
18855
+ }, function (_wasThrown2, _result3) {
18856
+ setMoveToCartLoading(false);
18857
+ if (_wasThrown2) throw _result3;
18858
+ return _result3;
18859
+ });
18860
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
18861
+ } catch (e) {
18862
+ return Promise.reject(e);
18863
+ }
18864
+ }
18865
+ }, product !== null && product !== void 0 && product.hasChildProduct ? 'Select Options' : moveToCartLoading ? 'Moving...' : 'Move to Cart') : /*#__PURE__*/React__default.createElement(OutOfStockButton$1, {
18866
+ variant: "contained",
18867
+ color: "primary",
18868
+ disabled: true,
18869
+ style: getStyleOverride$1(styleOverrides, 'outOfStockButton', 'OutOfStockButton'),
18870
+ onClick: function onClick(e) {
18871
+ var _e$stopPropagation3;
18872
+ return e === null || e === void 0 ? void 0 : (_e$stopPropagation3 = e.stopPropagation) === null || _e$stopPropagation3 === void 0 ? void 0 : _e$stopPropagation3.call(e);
18873
+ }
18874
+ }, "Out Of stock")));
18875
+ };
18876
+
18877
+ export { APIStaticPage, AccountDetails, BrandList, BrandStock, Breakpoint, CartDrawer, CartPageComponent, CheckoutPageComponent, ContactUsForm, FavoriteItemsComponent as FavoriteItems, GTagManager, HomeBanner, MaintenancePage, NewArrivalPage, OutOfStock, QuickOrder, RenderTawk, SingleBanner, SnowfallComponent as Snowfall, StaticPage, StaticPageList, SwitchUser, ThankYou, Variant, VendorAccountDetails as VendorAccount, WishlistComponent as Wishlist, useGridSize, useWindowSize };
18464
18878
  //# sourceMappingURL=index.modern.js.map