@salesgenterp/ui-components 0.4.558 → 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
@@ -574,7 +419,7 @@ var handleError = function handleError(_ref6) {
574
419
  if (url !== '/refreshToken') {
575
420
  if (!hideErrorMessage) {
576
421
  var _exceptionResponse$da, _exceptionResponse$da2, _exceptionResponse$da3, _exceptionResponse$da4;
577
- alert((exceptionResponse === null || exceptionResponse === void 0 ? void 0 : (_exceptionResponse$da = exceptionResponse.data) === null || _exceptionResponse$da === void 0 ? void 0 : (_exceptionResponse$da2 = _exceptionResponse$da.error) === null || _exceptionResponse$da2 === void 0 ? void 0 : _exceptionResponse$da2.message) || (exceptionResponse === null || exceptionResponse === void 0 ? void 0 : (_exceptionResponse$da3 = exceptionResponse.data) === null || _exceptionResponse$da3 === void 0 ? void 0 : (_exceptionResponse$da4 = _exceptionResponse$da3.error) === null || _exceptionResponse$da4 === void 0 ? void 0 : _exceptionResponse$da4.details) || errorMessage || 'Something went wrong.');
422
+ alert((exceptionResponse === null || exceptionResponse === void 0 ? void 0 : (_exceptionResponse$da = exceptionResponse.data) === null || _exceptionResponse$da === void 0 ? void 0 : (_exceptionResponse$da2 = _exceptionResponse$da.error) === null || _exceptionResponse$da2 === void 0 ? void 0 : _exceptionResponse$da2.details) || (exceptionResponse === null || exceptionResponse === void 0 ? void 0 : (_exceptionResponse$da3 = exceptionResponse.data) === null || _exceptionResponse$da3 === void 0 ? void 0 : (_exceptionResponse$da4 = _exceptionResponse$da3.error) === null || _exceptionResponse$da4 === void 0 ? void 0 : _exceptionResponse$da4.message) || errorMessage || 'Something went wrong.');
578
423
  }
579
424
  }
580
425
  if (getStatusWithData) {
@@ -1070,20 +915,20 @@ var normalizeSavedCreditCards = function normalizeSavedCreditCards(data) {
1070
915
  return {
1071
916
  profile: {
1072
917
  customerProfileId: ((_cards$ = cards[0]) === null || _cards$ === void 0 ? void 0 : _cards$.customerProfileId) || null,
1073
- paymentProfiles: cards.map(function (card) {
1074
- var _card$cardName, _card$cardName2;
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;
1075
920
  return {
1076
- customerPaymentProfileId: card.customerPaymentProfileId,
921
+ customerPaymentProfileId: card === null || card === void 0 ? void 0 : card.customerPaymentProfileId,
1077
922
  payment: {
1078
923
  creditCard: {
1079
- cardType: card.cardName || 'Card',
1080
- cardNumber: card.last4 ? "XXXX" + card.last4 : '',
1081
- expirationDate: card.expirationMonth && card.expirationYear ? card.expirationMonth + "/" + card.expirationYear : '----'
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) : '----'
1082
927
  }
1083
928
  },
1084
929
  billTo: {
1085
- firstName: ((_card$cardName = card.cardName) === null || _card$cardName === void 0 ? void 0 : _card$cardName.split(' ')[0]) || '',
1086
- lastName: ((_card$cardName2 = card.cardName) === null || _card$cardName2 === void 0 ? void 0 : _card$cardName2.split(' ').slice(1).join(' ')) || ''
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, ' ')) || ''
1087
932
  }
1088
933
  };
1089
934
  })
@@ -7045,9 +6890,11 @@ var MainContainer$2 = styled__default.div(_templateObject2$i || (_templateObject
7045
6890
 
7046
6891
  var _templateObject$s, _templateObject2$j, _templateObject3$d, _templateObject4$a, _templateObject5$6, _templateObject6$4, _templateObject7$3, _templateObject8$3, _templateObject9$3;
7047
6892
  var BrandStock = function BrandStock(_ref) {
7048
- var _Object$keys, _Object$keys2, _data$brands;
6893
+ var _data$brands, _Object$keys, _Object$keys2, _data$brands2;
7049
6894
  var storeData = _ref.storeData,
7050
6895
  apiEndPoint = _ref.apiEndPoint,
6896
+ storeIds = _ref.storeIds,
6897
+ storeId = _ref.storeId,
7051
6898
  _ref$colors = _ref.colors,
7052
6899
  colors = _ref$colors === void 0 ? {
7053
6900
  primaryColor: '#424242'
@@ -7055,60 +6902,123 @@ var BrandStock = function BrandStock(_ref) {
7055
6902
  var _useState = React.useState(_extends({}, storeData)),
7056
6903
  data = _useState[0],
7057
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;
7058
6909
  React.useEffect(function () {
7059
- (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() {
7060
6919
  try {
7061
- var _temp = _catch(function () {
7062
- return Promise.resolve(API({
7063
- apiEndPoint: apiEndPoint,
7064
- url: "/ecommerce/brand/list?size=9999"
7065
- })).then(function (brandList) {
7066
- setData(_extends({}, data, {
7067
- brands: brandList === null || brandList === void 0 ? void 0 : brandList.content
7068
- }));
7069
- });
7070
- }, function () {});
7071
- return _temp && _temp.then ? _temp.then(function () {}) : void 0;
7072
- } catch (e) {
7073
- Promise.reject(e);
7074
- }
7075
- })();
7076
- }, []);
7077
- var getBrandProducts = React.useCallback(function (_ref2) {
7078
- var brand = _ref2.brand;
7079
- try {
7080
- var storeId = erCookieStorage.getItem('storeId') || 2;
7081
- return Promise.resolve(_catch(function () {
7082
- var data = [];
7083
- return Promise.resolve(API({
7084
- apiEndPoint: apiEndPoint,
7085
- url: "/ecommerce/product/brand?brandIdList=" + (brand === null || brand === void 0 ? void 0 : brand.id) + "&storeIds=" + storeId + "&size=9999"
7086
- })).then(function (products) {
7087
- function _temp3() {
7088
- return Promise.resolve(Promise.all(updatePromises)).then(function () {
7089
- return data;
7090
- });
7091
- }
7092
- data = products === null || products === void 0 ? void 0 : products.content;
7093
- var updatePromises = [];
7094
- 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 () {
7095
6923
  return Promise.resolve(API({
7096
6924
  apiEndPoint: apiEndPoint,
7097
- url: "/ecommerce/product/" + (product === null || product === void 0 ? void 0 : product.productId) + "?storeIds=" + storeId
7098
- })).then(function (childProducts) {
7099
- var _childProducts$body;
7100
- 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
+ });
7101
6936
  });
6937
+ }, function () {
6938
+ if (!ignore) {
6939
+ setData(function (prev) {
6940
+ return _extends({}, prev, {
6941
+ brands: []
6942
+ });
6943
+ });
6944
+ }
7102
6945
  });
7103
- return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
7104
- });
7105
- }, function () {
7106
- 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
7107
6980
  }));
7108
- } catch (e) {
7109
- return Promise.reject(e);
7110
- }
7111
- }, []);
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
+ });
7112
7022
  return /*#__PURE__*/React__default.createElement(styled.ThemeProvider, {
7113
7023
  theme: colors
7114
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", {
@@ -7129,74 +7039,9 @@ var BrandStock = function BrandStock(_ref) {
7129
7039
  key: i,
7130
7040
  className: "lineContainer"
7131
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]));
7132
- }))), /*#__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) {
7133
- return /*#__PURE__*/React__default.createElement("div", {
7134
- style: {
7135
- margin: '1.2rem 0'
7136
- },
7137
- key: i
7138
- }, /*#__PURE__*/React__default.createElement(AsyncDataLoadComponent, {
7139
- apiEndPoint: apiEndPoint,
7140
- asyncService: function asyncService() {
7141
- return getBrandProducts({
7142
- brand: brand
7143
- });
7144
- }
7145
- }, function (products) {
7146
- var _brand$brandAttachmen, _brand$brandAttachmen2;
7147
- 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) {
7148
- return /*#__PURE__*/React__default.createElement("div", {
7149
- style: {
7150
- display: 'flex'
7151
- },
7152
- key: i
7153
- }, /*#__PURE__*/React__default.createElement("img", {
7154
- className: "brandImage",
7155
- alt: "logo",
7156
- src: (brand === null || brand === void 0 ? void 0 : brand.url) || noImgAvailable$1
7157
- }));
7158
- }), /*#__PURE__*/React__default.createElement("div", {
7159
- style: {
7160
- marginBottom: '0.4rem',
7161
- textAlign: 'center'
7162
- }
7163
- }, /*#__PURE__*/React__default.createElement("p", {
7164
- style: {
7165
- fontWeight: 600
7166
- }
7167
- }, 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, {
7168
- component: Paper
7169
- }, /*#__PURE__*/React__default.createElement(Table, {
7170
- "aria-label": "simple table",
7171
- size: "small"
7172
- }, /*#__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, {
7173
- align: "right"
7174
- }, /*#__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) {
7175
- var _product$childProduct, _product$childProduct2;
7176
- 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) {
7177
- return /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7178
- key: i,
7179
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7180
- }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7181
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7182
- }, child === null || child === void 0 ? void 0 : child.productName), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7183
- align: "right",
7184
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0,
7185
- stockCol: true
7186
- }, child.availableQuantity > 0 ? 'In Stock' : 'Out of Stock'));
7187
- }) : /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7188
- key: i,
7189
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7190
- }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7191
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7192
- }, product === null || product === void 0 ? void 0 : product.productName), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7193
- align: "right",
7194
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0,
7195
- stockCol: true
7196
- }, (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0 ? 'In Stock' : 'Out of Stock'));
7197
- }) : /*#__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))))));
7198
- }));
7199
- })), (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))));
7200
7045
  };
7201
7046
  var Root$9 = styled__default.div(_templateObject$s || (_templateObject$s = _taggedTemplateLiteralLoose(["\n padding: 1rem;\n"])));
7202
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"])));
@@ -18548,6 +18393,491 @@ var ProductCard = function ProductCard(_ref4) {
18548
18393
  }, "Out Of stock")));
18549
18394
  };
18550
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
+
18551
18881
  exports.APIStaticPage = APIStaticPage;
18552
18882
  exports.AccountDetails = AccountDetails;
18553
18883
  exports.BrandList = BrandList;
@@ -18557,6 +18887,7 @@ exports.CartDrawer = CartDrawer;
18557
18887
  exports.CartPageComponent = CartPageComponent;
18558
18888
  exports.CheckoutPageComponent = CheckoutPageComponent;
18559
18889
  exports.ContactUsForm = ContactUsForm;
18890
+ exports.FavoriteItems = FavoriteItemsComponent;
18560
18891
  exports.GTagManager = GTagManager;
18561
18892
  exports.HomeBanner = HomeBanner;
18562
18893
  exports.MaintenancePage = MaintenancePage;