@salesgenterp/ui-components 0.4.558 → 0.4.560

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
@@ -570,7 +415,7 @@ var handleError = function handleError(_ref6) {
570
415
  if (url !== '/refreshToken') {
571
416
  if (!hideErrorMessage) {
572
417
  var _exceptionResponse$da, _exceptionResponse$da2, _exceptionResponse$da3, _exceptionResponse$da4;
573
- 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.');
418
+ 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.');
574
419
  }
575
420
  }
576
421
  if (getStatusWithData) {
@@ -1066,20 +911,20 @@ var normalizeSavedCreditCards = function normalizeSavedCreditCards(data) {
1066
911
  return {
1067
912
  profile: {
1068
913
  customerProfileId: ((_cards$ = cards[0]) === null || _cards$ === void 0 ? void 0 : _cards$.customerProfileId) || null,
1069
- paymentProfiles: cards.map(function (card) {
1070
- var _card$cardName, _card$cardName2;
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;
1071
916
  return {
1072
- customerPaymentProfileId: card.customerPaymentProfileId,
917
+ customerPaymentProfileId: card === null || card === void 0 ? void 0 : card.customerPaymentProfileId,
1073
918
  payment: {
1074
919
  creditCard: {
1075
- cardType: card.cardName || 'Card',
1076
- cardNumber: card.last4 ? "XXXX" + card.last4 : '',
1077
- expirationDate: card.expirationMonth && card.expirationYear ? card.expirationMonth + "/" + card.expirationYear : '----'
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) : '----'
1078
923
  }
1079
924
  },
1080
925
  billTo: {
1081
- firstName: ((_card$cardName = card.cardName) === null || _card$cardName === void 0 ? void 0 : _card$cardName.split(' ')[0]) || '',
1082
- lastName: ((_card$cardName2 = card.cardName) === null || _card$cardName2 === void 0 ? void 0 : _card$cardName2.split(' ').slice(1).join(' ')) || ''
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, ' ')) || ''
1083
928
  }
1084
929
  };
1085
930
  })
@@ -7041,9 +6886,11 @@ var MainContainer$2 = styled.div(_templateObject2$i || (_templateObject2$i = _ta
7041
6886
 
7042
6887
  var _templateObject$s, _templateObject2$j, _templateObject3$d, _templateObject4$a, _templateObject5$6, _templateObject6$4, _templateObject7$3, _templateObject8$3, _templateObject9$3;
7043
6888
  var BrandStock = function BrandStock(_ref) {
7044
- var _Object$keys, _Object$keys2, _data$brands;
6889
+ var _data$brands, _Object$keys, _Object$keys2, _data$brands2;
7045
6890
  var storeData = _ref.storeData,
7046
6891
  apiEndPoint = _ref.apiEndPoint,
6892
+ storeIds = _ref.storeIds,
6893
+ storeId = _ref.storeId,
7047
6894
  _ref$colors = _ref.colors,
7048
6895
  colors = _ref$colors === void 0 ? {
7049
6896
  primaryColor: '#424242'
@@ -7051,60 +6898,123 @@ var BrandStock = function BrandStock(_ref) {
7051
6898
  var _useState = useState(_extends({}, storeData)),
7052
6899
  data = _useState[0],
7053
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;
7054
6905
  useEffect(function () {
7055
- (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() {
7056
6915
  try {
7057
- var _temp = _catch(function () {
7058
- return Promise.resolve(API({
7059
- apiEndPoint: apiEndPoint,
7060
- url: "/ecommerce/brand/list?size=9999"
7061
- })).then(function (brandList) {
7062
- setData(_extends({}, data, {
7063
- brands: brandList === null || brandList === void 0 ? void 0 : brandList.content
7064
- }));
7065
- });
7066
- }, function () {});
7067
- return _temp && _temp.then ? _temp.then(function () {}) : void 0;
7068
- } catch (e) {
7069
- Promise.reject(e);
7070
- }
7071
- })();
7072
- }, []);
7073
- var getBrandProducts = useCallback(function (_ref2) {
7074
- var brand = _ref2.brand;
7075
- try {
7076
- var storeId = erCookieStorage.getItem('storeId') || 2;
7077
- return Promise.resolve(_catch(function () {
7078
- var data = [];
7079
- return Promise.resolve(API({
7080
- apiEndPoint: apiEndPoint,
7081
- url: "/ecommerce/product/brand?brandIdList=" + (brand === null || brand === void 0 ? void 0 : brand.id) + "&storeIds=" + storeId + "&size=9999"
7082
- })).then(function (products) {
7083
- function _temp3() {
7084
- return Promise.resolve(Promise.all(updatePromises)).then(function () {
7085
- return data;
7086
- });
7087
- }
7088
- data = products === null || products === void 0 ? void 0 : products.content;
7089
- var updatePromises = [];
7090
- 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 () {
7091
6919
  return Promise.resolve(API({
7092
6920
  apiEndPoint: apiEndPoint,
7093
- url: "/ecommerce/product/" + (product === null || product === void 0 ? void 0 : product.productId) + "?storeIds=" + storeId
7094
- })).then(function (childProducts) {
7095
- var _childProducts$body;
7096
- 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
+ });
7097
6932
  });
6933
+ }, function () {
6934
+ if (!ignore) {
6935
+ setData(function (prev) {
6936
+ return _extends({}, prev, {
6937
+ brands: []
6938
+ });
6939
+ });
6940
+ }
7098
6941
  });
7099
- return _temp2 && _temp2.then ? _temp2.then(_temp3) : _temp3(_temp2);
7100
- });
7101
- }, function () {
7102
- 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
7103
6976
  }));
7104
- } catch (e) {
7105
- return Promise.reject(e);
7106
- }
7107
- }, []);
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
+ });
7108
7018
  return /*#__PURE__*/React__default.createElement(ThemeProvider, {
7109
7019
  theme: colors
7110
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", {
@@ -7125,74 +7035,9 @@ var BrandStock = function BrandStock(_ref) {
7125
7035
  key: i,
7126
7036
  className: "lineContainer"
7127
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]));
7128
- }))), /*#__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) {
7129
- return /*#__PURE__*/React__default.createElement("div", {
7130
- style: {
7131
- margin: '1.2rem 0'
7132
- },
7133
- key: i
7134
- }, /*#__PURE__*/React__default.createElement(AsyncDataLoadComponent, {
7135
- apiEndPoint: apiEndPoint,
7136
- asyncService: function asyncService() {
7137
- return getBrandProducts({
7138
- brand: brand
7139
- });
7140
- }
7141
- }, function (products) {
7142
- var _brand$brandAttachmen, _brand$brandAttachmen2;
7143
- 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) {
7144
- return /*#__PURE__*/React__default.createElement("div", {
7145
- style: {
7146
- display: 'flex'
7147
- },
7148
- key: i
7149
- }, /*#__PURE__*/React__default.createElement("img", {
7150
- className: "brandImage",
7151
- alt: "logo",
7152
- src: (brand === null || brand === void 0 ? void 0 : brand.url) || noImgAvailable$1
7153
- }));
7154
- }), /*#__PURE__*/React__default.createElement("div", {
7155
- style: {
7156
- marginBottom: '0.4rem',
7157
- textAlign: 'center'
7158
- }
7159
- }, /*#__PURE__*/React__default.createElement("p", {
7160
- style: {
7161
- fontWeight: 600
7162
- }
7163
- }, 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, {
7164
- component: Paper$1
7165
- }, /*#__PURE__*/React__default.createElement(Table$1, {
7166
- "aria-label": "simple table",
7167
- size: "small"
7168
- }, /*#__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, {
7169
- align: "right"
7170
- }, /*#__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) {
7171
- var _product$childProduct, _product$childProduct2;
7172
- 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) {
7173
- return /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7174
- key: i,
7175
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7176
- }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7177
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0
7178
- }, child === null || child === void 0 ? void 0 : child.productName), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7179
- align: "right",
7180
- availableQuantity: (child === null || child === void 0 ? void 0 : child.availableQuantity) > 0,
7181
- stockCol: true
7182
- }, child.availableQuantity > 0 ? 'In Stock' : 'Out of Stock'));
7183
- }) : /*#__PURE__*/React__default.createElement(TableRowContainer$1, {
7184
- key: i,
7185
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7186
- }, /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7187
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0
7188
- }, product === null || product === void 0 ? void 0 : product.productName), /*#__PURE__*/React__default.createElement(TableCellContainer$1, {
7189
- align: "right",
7190
- availableQuantity: (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0,
7191
- stockCol: true
7192
- }, (product === null || product === void 0 ? void 0 : product.availableQuantity) > 0 ? 'In Stock' : 'Out of Stock'));
7193
- }) : /*#__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))))));
7194
- }));
7195
- })), (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))));
7196
7041
  };
7197
7042
  var Root$9 = styled.div(_templateObject$s || (_templateObject$s = _taggedTemplateLiteralLoose(["\n padding: 1rem;\n"])));
7198
7043
  var TitleContainer$1 = styled.div(_templateObject2$j || (_templateObject2$j = _taggedTemplateLiteralLoose(["\n padding: 0 1rem;\n display: flex;\n justify-content: space-between;\n"])));
@@ -18544,5 +18389,481 @@ var ProductCard = function ProductCard(_ref4) {
18544
18389
  }, "Out Of stock")));
18545
18390
  };
18546
18391
 
18547
- 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 DEFAULT_GRID_SPAN$1 = {
18534
+ lg: 3,
18535
+ md: 4,
18536
+ sm: 6,
18537
+ xs: 6
18538
+ };
18539
+ var getStyleOverride$1 = function getStyleOverride(styleOverrides) {
18540
+ for (var _len = arguments.length, keys = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
18541
+ keys[_key - 1] = arguments[_key];
18542
+ }
18543
+ for (var _i = 0, _keys = keys; _i < _keys.length; _i++) {
18544
+ var key = _keys[_i];
18545
+ if (styleOverrides !== null && styleOverrides !== void 0 && styleOverrides[key]) return styleOverrides[key];
18546
+ }
18547
+ return undefined;
18548
+ };
18549
+ var normalizeFavoriteItems = function normalizeFavoriteItems(data) {
18550
+ if (Array.isArray(data)) return data.filter(Boolean);
18551
+ var content = data === null || data === void 0 ? void 0 : data.content;
18552
+ return Array.isArray(content) ? content.filter(Boolean) : [];
18553
+ };
18554
+ var getFavoriteItemsTotal = function getFavoriteItemsTotal(data, items) {
18555
+ var _items$length;
18556
+ if (typeof (data === null || data === void 0 ? void 0 : data.totalElements) === 'number') {
18557
+ return data === null || data === void 0 ? void 0 : data.totalElements;
18558
+ }
18559
+ return (_items$length = items === null || items === void 0 ? void 0 : items.length) != null ? _items$length : 0;
18560
+ };
18561
+ var FavoriteItemsContent = function FavoriteItemsContent(_ref) {
18562
+ var data = _ref.data,
18563
+ apiEndPoint = _ref.apiEndPoint,
18564
+ token = _ref.token,
18565
+ searchInput = _ref.searchInput,
18566
+ onSearchChange = _ref.onSearchChange,
18567
+ styleOverrides = _ref.styleOverrides,
18568
+ gridSpan = _ref.gridSpan,
18569
+ primaryColor = _ref.primaryColor,
18570
+ onMoveToCart = _ref.onMoveToCart,
18571
+ onProductCardClick = _ref.onProductCardClick,
18572
+ _ref$imgNotFoundUrl = _ref.imgNotFoundUrl,
18573
+ imgNotFoundUrl = _ref$imgNotFoundUrl === void 0 ? '' : _ref$imgNotFoundUrl,
18574
+ setRefreshTrigger = _ref.setRefreshTrigger,
18575
+ allowToProcessInvoiceForOutOfStockProducts = _ref.allowToProcessInvoiceForOutOfStockProducts;
18576
+ var items = useMemo(function () {
18577
+ return normalizeFavoriteItems(data);
18578
+ }, [data]);
18579
+ var totalItems = useMemo(function () {
18580
+ return getFavoriteItemsTotal(data, items);
18581
+ }, [data, items]);
18582
+ return /*#__PURE__*/React__default.createElement("div", {
18583
+ style: {
18584
+ width: '100%',
18585
+ height: '100%'
18586
+ }
18587
+ }, /*#__PURE__*/React__default.createElement(TopBar$1, {
18588
+ style: getStyleOverride$1(styleOverrides, 'topBar', 'TopBar')
18589
+ }, /*#__PURE__*/React__default.createElement(SearchWrapper$1, {
18590
+ style: getStyleOverride$1(styleOverrides, 'searchWrapper', 'SearchWrapper')
18591
+ }, /*#__PURE__*/React__default.createElement(TextField, {
18592
+ placeholder: "Type minimum 3 characters to search...",
18593
+ value: searchInput,
18594
+ onChange: onSearchChange,
18595
+ size: "small",
18596
+ fullWidth: true,
18597
+ sx: {
18598
+ '& .MuiOutlinedInput-root': {
18599
+ borderRadius: '8px'
18600
+ }
18601
+ }
18602
+ })), /*#__PURE__*/React__default.createElement(TotalItemsText$1, {
18603
+ style: getStyleOverride$1(styleOverrides, 'totalItemsText', 'TotalItemsText')
18604
+ }, "Total " + totalItems + " item" + (totalItems === 1 ? '' : 's'))), !(items !== null && items !== void 0 && items.length) ? /*#__PURE__*/React__default.createElement(EmptyStateText$1, {
18605
+ style: getStyleOverride$1(styleOverrides, 'emptyStateText', 'EmptyStateText')
18606
+ }, "No favorite items found") : /*#__PURE__*/React__default.createElement(Grid, {
18607
+ container: true,
18608
+ spacing: 2
18609
+ }, items === null || items === void 0 ? void 0 : items.map(function (product, index) {
18610
+ var _ref2, _product$id;
18611
+ return /*#__PURE__*/React__default.createElement(Grid, {
18612
+ item: true,
18613
+ xs: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.xs,
18614
+ sm: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.sm,
18615
+ md: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.md,
18616
+ lg: gridSpan === null || gridSpan === void 0 ? void 0 : gridSpan.lg,
18617
+ 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
18618
+ }, /*#__PURE__*/React__default.createElement(ProductCard$1, {
18619
+ setRefreshTrigger: setRefreshTrigger,
18620
+ apiEndPoint: apiEndPoint,
18621
+ token: token,
18622
+ product: product,
18623
+ styleOverrides: styleOverrides,
18624
+ primaryColor: primaryColor,
18625
+ onMoveToCart: onMoveToCart,
18626
+ onProductCardClick: onProductCardClick,
18627
+ imgNotFoundUrl: imgNotFoundUrl,
18628
+ allowToProcessInvoiceForOutOfStockProducts: allowToProcessInvoiceForOutOfStockProducts
18629
+ }));
18630
+ })));
18631
+ };
18632
+ var FavoriteItemsComponent = function FavoriteItemsComponent(_ref3) {
18633
+ var _ref3$style = _ref3.style,
18634
+ style = _ref3$style === void 0 ? {} : _ref3$style,
18635
+ token = _ref3.token,
18636
+ _ref3$span = _ref3.span,
18637
+ span = _ref3$span === void 0 ? DEFAULT_GRID_SPAN$1 : _ref3$span,
18638
+ primaryColor = _ref3.primaryColor,
18639
+ apiEndPoint = _ref3.apiEndPoint,
18640
+ onMoveToCart = _ref3.onMoveToCart,
18641
+ onProductCardClick = _ref3.onProductCardClick,
18642
+ _ref3$allowToProcessI = _ref3.allowToProcessInvoiceForOutOfStockProducts,
18643
+ allowToProcessInvoiceForOutOfStockProducts = _ref3$allowToProcessI === void 0 ? false : _ref3$allowToProcessI;
18644
+ var styleOverrides = useMemo(function () {
18645
+ return _extends({}, style || {});
18646
+ }, [style]);
18647
+ var _useState = useState(''),
18648
+ searchInput = _useState[0],
18649
+ setSearchInput = _useState[1];
18650
+ var _useState2 = useState(''),
18651
+ searchQuery = _useState2[0],
18652
+ setSearchQuery = _useState2[1];
18653
+ var _useState3 = useState(0),
18654
+ refreshTrigger = _useState3[0],
18655
+ setRefreshTrigger = _useState3[1];
18656
+ var gridSpan = useMemo(function () {
18657
+ return _extends({}, DEFAULT_GRID_SPAN$1, span || {});
18658
+ }, [span]);
18659
+ var debouncedSearch = useMemo(function () {
18660
+ return debounce$1(function (value) {
18661
+ var normalizedValue = value != null ? value : '';
18662
+ if ((normalizedValue === null || normalizedValue === void 0 ? void 0 : normalizedValue.length) === 0 || (normalizedValue === null || normalizedValue === void 0 ? void 0 : normalizedValue.length) >= 3) {
18663
+ setSearchQuery(normalizedValue);
18664
+ }
18665
+ }, 500);
18666
+ }, []);
18667
+ useEffect(function () {
18668
+ return function () {
18669
+ var _debouncedSearch$canc;
18670
+ debouncedSearch === null || debouncedSearch === void 0 ? void 0 : (_debouncedSearch$canc = debouncedSearch.cancel) === null || _debouncedSearch$canc === void 0 ? void 0 : _debouncedSearch$canc.call(debouncedSearch);
18671
+ };
18672
+ }, [debouncedSearch]);
18673
+ var handleSearchChange = useCallback(function (e) {
18674
+ var _e$target$value, _e$target;
18675
+ 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 : '';
18676
+ setSearchInput(value);
18677
+ debouncedSearch(value);
18678
+ }, [debouncedSearch]);
18679
+ var favoriteItemsTrigger = useMemo(function () {
18680
+ return searchQuery + "-" + refreshTrigger;
18681
+ }, [searchQuery, refreshTrigger]);
18682
+ var favoriteItemsAsyncService = useCallback(function () {
18683
+ return getFavoriteItemsData({
18684
+ apiEndPoint: apiEndPoint,
18685
+ token: token,
18686
+ queryParams: _extends({
18687
+ page: 0,
18688
+ size: 9999
18689
+ }, searchQuery ? {
18690
+ productName: searchQuery
18691
+ } : {})
18692
+ });
18693
+ }, [apiEndPoint, token, searchQuery]);
18694
+ var favoriteItemsLoadingView = useMemo(function () {
18695
+ return /*#__PURE__*/React__default.createElement(FavoriteItemsProductCardSkeleton, {
18696
+ span: span
18697
+ });
18698
+ }, [span]);
18699
+ if (!token) {
18700
+ 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."));
18701
+ }
18702
+ if (!apiEndPoint) {
18703
+ return /*#__PURE__*/React__default.createElement(EmptyStateText$1, null, "Unable to load favorite items. API endpoint is not configured.");
18704
+ }
18705
+ return /*#__PURE__*/React__default.createElement("div", {
18706
+ style: {
18707
+ marginTop: '1rem',
18708
+ height: '100%',
18709
+ width: '100%'
18710
+ }
18711
+ }, /*#__PURE__*/React__default.createElement(AsyncDataLoadComponent, {
18712
+ asyncService: favoriteItemsAsyncService,
18713
+ triggerChange: favoriteItemsTrigger,
18714
+ loadingView: favoriteItemsLoadingView
18715
+ }, function (data) {
18716
+ return /*#__PURE__*/React__default.createElement(FavoriteItemsContent, {
18717
+ data: data,
18718
+ apiEndPoint: apiEndPoint,
18719
+ token: token,
18720
+ searchInput: searchInput,
18721
+ onSearchChange: handleSearchChange,
18722
+ styleOverrides: styleOverrides,
18723
+ gridSpan: gridSpan,
18724
+ primaryColor: primaryColor,
18725
+ onMoveToCart: onMoveToCart,
18726
+ onProductCardClick: onProductCardClick,
18727
+ setRefreshTrigger: setRefreshTrigger,
18728
+ allowToProcessInvoiceForOutOfStockProducts: allowToProcessInvoiceForOutOfStockProducts
18729
+ });
18730
+ }));
18731
+ };
18732
+ var ProductCard$1 = function ProductCard(_ref4) {
18733
+ var product = _ref4.product,
18734
+ styleOverrides = _ref4.styleOverrides,
18735
+ primaryColor = _ref4.primaryColor,
18736
+ onMoveToCart = _ref4.onMoveToCart,
18737
+ onProductCardClick = _ref4.onProductCardClick,
18738
+ _ref4$imgNotFoundUrl = _ref4.imgNotFoundUrl,
18739
+ imgNotFoundUrl = _ref4$imgNotFoundUrl === void 0 ? '' : _ref4$imgNotFoundUrl,
18740
+ apiEndPoint = _ref4.apiEndPoint,
18741
+ token = _ref4.token,
18742
+ setRefreshTrigger = _ref4.setRefreshTrigger,
18743
+ allowToProcessInvoiceForOutOfStockProducts = _ref4.allowToProcessInvoiceForOutOfStockProducts;
18744
+ var _useState4 = useState(false),
18745
+ deleteLoading = _useState4[0],
18746
+ setDeleteLoading = _useState4[1];
18747
+ var _useState5 = useState(false),
18748
+ moveToCartLoading = _useState5[0],
18749
+ setMoveToCartLoading = _useState5[1];
18750
+ if (!product) return null;
18751
+ var removeItem = function removeItem(item) {
18752
+ try {
18753
+ if ((item === null || item === void 0 ? void 0 : item.productId) == null) return Promise.resolve();
18754
+ setDeleteLoading(true);
18755
+ var _temp = _finallyRethrows(function () {
18756
+ return _catch(function () {
18757
+ return Promise.resolve(removeFromFavoriteItems({
18758
+ apiEndPoint: apiEndPoint,
18759
+ token: token,
18760
+ productId: item === null || item === void 0 ? void 0 : item.productId
18761
+ })).then(function () {
18762
+ setRefreshTrigger === null || setRefreshTrigger === void 0 ? void 0 : setRefreshTrigger(function (prev) {
18763
+ return prev + 1;
18764
+ });
18765
+ });
18766
+ }, function () {});
18767
+ }, function (_wasThrown, _result) {
18768
+ setDeleteLoading(false);
18769
+ if (_wasThrown) throw _result;
18770
+ return _result;
18771
+ });
18772
+ return Promise.resolve(_temp && _temp.then ? _temp.then(function () {}) : void 0);
18773
+ } catch (e) {
18774
+ return Promise.reject(e);
18775
+ }
18776
+ };
18777
+ return /*#__PURE__*/React__default.createElement(ProductCardWrapper$1, {
18778
+ style: getStyleOverride$1(styleOverrides, 'productCardWrapper', 'ProductCardWrapper'),
18779
+ onClick: function onClick() {
18780
+ onProductCardClick === null || onProductCardClick === void 0 ? void 0 : onProductCardClick(product);
18781
+ }
18782
+ }, /*#__PURE__*/React__default.createElement(DeleteButton$1, {
18783
+ type: "button",
18784
+ className: "favorite-items-delete-btn",
18785
+ "aria-label": "Remove from favorites",
18786
+ style: getStyleOverride$1(styleOverrides, 'deleteButton', 'DeleteButton'),
18787
+ onClick: function onClick(e) {
18788
+ try {
18789
+ var _e$stopPropagation;
18790
+ e === null || e === void 0 ? void 0 : (_e$stopPropagation = e.stopPropagation) === null || _e$stopPropagation === void 0 ? void 0 : _e$stopPropagation.call(e);
18791
+ return Promise.resolve(_catch(function () {
18792
+ var _window, _window$confirm;
18793
+ 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?');
18794
+ if (!confirm) return;
18795
+ return Promise.resolve(removeItem(product)).then(function () {});
18796
+ }, function () {}));
18797
+ } catch (e) {
18798
+ return Promise.reject(e);
18799
+ }
18800
+ }
18801
+ }, deleteLoading ? /*#__PURE__*/React__default.createElement(CircularProgress, {
18802
+ size: 20
18803
+ }) : /*#__PURE__*/React__default.createElement(AiOutlineDelete, {
18804
+ style: {
18805
+ fontSize: 18
18806
+ }
18807
+ })), /*#__PURE__*/React__default.createElement(Image$3, {
18808
+ src: getProductImage$1(product === null || product === void 0 ? void 0 : product.imageUrl, imgNotFoundUrl),
18809
+ alt: (product === null || product === void 0 ? void 0 : product.productName) || 'Product',
18810
+ width: 160,
18811
+ height: 160,
18812
+ objectFit: "contain"
18813
+ }), /*#__PURE__*/React__default.createElement(ProductName$3, {
18814
+ style: getStyleOverride$1(styleOverrides, 'productName', 'ProductName')
18815
+ }, 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, {
18816
+ variant: "contained",
18817
+ color: "primary",
18818
+ primaryColor: primaryColor,
18819
+ style: getStyleOverride$1(styleOverrides, 'productActionButton', 'ProductActionButton'),
18820
+ disabled: moveToCartLoading,
18821
+ onClick: function onClick(e) {
18822
+ try {
18823
+ var _e$stopPropagation2, _e$preventDefault;
18824
+ e === null || e === void 0 ? void 0 : (_e$stopPropagation2 = e.stopPropagation) === null || _e$stopPropagation2 === void 0 ? void 0 : _e$stopPropagation2.call(e);
18825
+ e === null || e === void 0 ? void 0 : (_e$preventDefault = e.preventDefault) === null || _e$preventDefault === void 0 ? void 0 : _e$preventDefault.call(e);
18826
+ if (product !== null && product !== void 0 && product.hasChildProduct) {
18827
+ onProductCardClick === null || onProductCardClick === void 0 ? void 0 : onProductCardClick(product);
18828
+ return Promise.resolve();
18829
+ }
18830
+ var productId = product === null || product === void 0 ? void 0 : product.id;
18831
+ if (productId == null) return Promise.resolve();
18832
+ setMoveToCartLoading(true);
18833
+ var _temp2 = _finallyRethrows(function () {
18834
+ return _catch(function () {
18835
+ return Promise.resolve(moveToCartFromFavoriteItems({
18836
+ apiEndPoint: apiEndPoint,
18837
+ token: token,
18838
+ productId: productId
18839
+ })).then(function () {
18840
+ setRefreshTrigger === null || setRefreshTrigger === void 0 ? void 0 : setRefreshTrigger(function (prev) {
18841
+ return prev + 1;
18842
+ });
18843
+ onMoveToCart === null || onMoveToCart === void 0 ? void 0 : onMoveToCart(product);
18844
+ });
18845
+ }, function () {});
18846
+ }, function (_wasThrown2, _result3) {
18847
+ setMoveToCartLoading(false);
18848
+ if (_wasThrown2) throw _result3;
18849
+ return _result3;
18850
+ });
18851
+ return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function () {}) : void 0);
18852
+ } catch (e) {
18853
+ return Promise.reject(e);
18854
+ }
18855
+ }
18856
+ }, product !== null && product !== void 0 && product.hasChildProduct ? 'Select Options' : moveToCartLoading ? 'Moving...' : 'Move to Cart') : /*#__PURE__*/React__default.createElement(OutOfStockButton$1, {
18857
+ variant: "contained",
18858
+ color: "primary",
18859
+ disabled: true,
18860
+ style: getStyleOverride$1(styleOverrides, 'outOfStockButton', 'OutOfStockButton'),
18861
+ onClick: function onClick(e) {
18862
+ var _e$stopPropagation3;
18863
+ return e === null || e === void 0 ? void 0 : (_e$stopPropagation3 = e.stopPropagation) === null || _e$stopPropagation3 === void 0 ? void 0 : _e$stopPropagation3.call(e);
18864
+ }
18865
+ }, "Out Of stock")));
18866
+ };
18867
+
18868
+ 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 };
18548
18869
  //# sourceMappingURL=index.modern.js.map