ordering-components-external 13.2.20 → 13.2.22
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/_bundles/{7.ordering-component.0a164d98b183999274c5.js → 7.ordering-component.708e27a828acb42dafde.js} +1 -1
- package/_bundles/ordering-component.708e27a828acb42dafde.js +2 -0
- package/_modules/components/AddressForm/index.js +39 -25
- package/_modules/components/BusinessAndProductList/index.js +22 -3
- package/_modules/components/OrderDetails/index.js +2 -2
- package/package.json +1 -1
- package/src/components/AddressForm/index.js +11 -3
- package/src/components/BusinessAndProductList/index.js +22 -3
- package/_bundles/ordering-component.0a164d98b183999274c5.js +0 -2
- /package/_bundles/{0.ordering-component.0a164d98b183999274c5.js → 0.ordering-component.708e27a828acb42dafde.js} +0 -0
- /package/_bundles/{1.ordering-component.0a164d98b183999274c5.js → 1.ordering-component.708e27a828acb42dafde.js} +0 -0
- /package/_bundles/{2.ordering-component.0a164d98b183999274c5.js → 2.ordering-component.708e27a828acb42dafde.js} +0 -0
- /package/_bundles/{4.ordering-component.0a164d98b183999274c5.js → 4.ordering-component.708e27a828acb42dafde.js} +0 -0
- /package/_bundles/{5.ordering-component.0a164d98b183999274c5.js → 5.ordering-component.708e27a828acb42dafde.js} +0 -0
- /package/_bundles/{6.ordering-component.0a164d98b183999274c5.js → 6.ordering-component.708e27a828acb42dafde.js} +0 -0
- /package/_bundles/{7.ordering-component.0a164d98b183999274c5.js.LICENSE.txt → 7.ordering-component.708e27a828acb42dafde.js.LICENSE.txt} +0 -0
- /package/_bundles/{8.ordering-component.0a164d98b183999274c5.js → 8.ordering-component.708e27a828acb42dafde.js} +0 -0
- /package/_bundles/{ordering-component.0a164d98b183999274c5.js.LICENSE.txt → ordering-component.708e27a828acb42dafde.js.LICENSE.txt} +0 -0
|
@@ -193,7 +193,7 @@ var AddressForm = exports.AddressForm = function AddressForm(props) {
|
|
|
193
193
|
var saveAddress = /*#__PURE__*/function () {
|
|
194
194
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(values, userCustomerSetup) {
|
|
195
195
|
var _userByToken$session;
|
|
196
|
-
var _values$country_code, _formState$changes, _addressState$address, _userByToken$session2, _yield$ordering$users2, content, _content$result;
|
|
196
|
+
var _values$country_code, _formState$changes, _addressState$address, _userByToken$session2, data, _yield$ordering$users2, content, _content$result;
|
|
197
197
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
198
198
|
while (1) switch (_context2.prev = _context2.next) {
|
|
199
199
|
case 0:
|
|
@@ -218,57 +218,71 @@ var AddressForm = exports.AddressForm = function AddressForm(props) {
|
|
|
218
218
|
loading: true
|
|
219
219
|
}));
|
|
220
220
|
_context2.prev = 8;
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
data = _objectSpread(_objectSpread({}, values), formState.changes);
|
|
222
|
+
Object.keys(data).forEach(function (key) {
|
|
223
|
+
if (data[key] === null) {
|
|
224
|
+
delete data[key];
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
_context2.next = 13;
|
|
228
|
+
return ordering.users((userByToken === null || userByToken === void 0 ? void 0 : userByToken.id) || userId).addresses((_addressState$address = addressState.address) === null || _addressState$address === void 0 ? void 0 : _addressState$address.id).save(data, {
|
|
223
229
|
accessToken: (userByToken === null || userByToken === void 0 || (_userByToken$session2 = userByToken.session) === null || _userByToken$session2 === void 0 ? void 0 : _userByToken$session2.token) || accessToken
|
|
224
230
|
});
|
|
225
|
-
case
|
|
231
|
+
case 13:
|
|
226
232
|
_yield$ordering$users2 = _context2.sent;
|
|
227
233
|
content = _yield$ordering$users2.content;
|
|
228
234
|
setFormState(_objectSpread(_objectSpread({}, formState), {}, {
|
|
229
235
|
loading: false,
|
|
230
236
|
error: content.error ? content.result : null,
|
|
237
|
+
result: content.result,
|
|
231
238
|
changes: content.error ? formState.changes : {}
|
|
232
239
|
}));
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}));
|
|
237
|
-
onSaveAddress && onSaveAddress(content.result);
|
|
238
|
-
if (isSelectedAfterAdd) {
|
|
239
|
-
changeAddress(content.result.id, {
|
|
240
|
-
address: isEdit ? null : content.result,
|
|
241
|
-
country_code: (_content$result = content.result) === null || _content$result === void 0 ? void 0 : _content$result.country_code,
|
|
242
|
-
type: options === null || options === void 0 ? void 0 : options.type,
|
|
243
|
-
isEdit: isEdit
|
|
244
|
-
});
|
|
245
|
-
}
|
|
240
|
+
if (content.error) {
|
|
241
|
+
_context2.next = 22;
|
|
242
|
+
break;
|
|
246
243
|
}
|
|
244
|
+
setAddressState(_objectSpread(_objectSpread({}, addressState), {}, {
|
|
245
|
+
address: content.result
|
|
246
|
+
}));
|
|
247
|
+
if (!isSelectedAfterAdd) {
|
|
248
|
+
_context2.next = 21;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
_context2.next = 21;
|
|
252
|
+
return changeAddress(content.result.id, {
|
|
253
|
+
address: isEdit ? null : content.result,
|
|
254
|
+
country_code: (_content$result = content.result) === null || _content$result === void 0 ? void 0 : _content$result.country_code,
|
|
255
|
+
type: options === null || options === void 0 ? void 0 : options.type,
|
|
256
|
+
isEdit: isEdit
|
|
257
|
+
});
|
|
258
|
+
case 21:
|
|
259
|
+
onSaveAddress && onSaveAddress(content.result);
|
|
260
|
+
case 22:
|
|
247
261
|
if (!userCustomerSetup) {
|
|
248
|
-
_context2.next =
|
|
262
|
+
_context2.next = 25;
|
|
249
263
|
break;
|
|
250
264
|
}
|
|
251
|
-
_context2.next =
|
|
265
|
+
_context2.next = 25;
|
|
252
266
|
return setUserCustomer(userCustomerSetup, true);
|
|
253
|
-
case
|
|
267
|
+
case 25:
|
|
254
268
|
if (!avoidRefreshUserInfo) {
|
|
255
269
|
refreshUserInfo();
|
|
256
270
|
}
|
|
257
|
-
_context2.next =
|
|
271
|
+
_context2.next = 31;
|
|
258
272
|
break;
|
|
259
|
-
case
|
|
260
|
-
_context2.prev =
|
|
273
|
+
case 28:
|
|
274
|
+
_context2.prev = 28;
|
|
261
275
|
_context2.t0 = _context2["catch"](8);
|
|
262
276
|
setFormState(_objectSpread(_objectSpread({}, formState), {}, {
|
|
263
277
|
loading: false,
|
|
264
278
|
error: [_context2.t0.message],
|
|
265
279
|
address: {}
|
|
266
280
|
}));
|
|
267
|
-
case
|
|
281
|
+
case 31:
|
|
268
282
|
case "end":
|
|
269
283
|
return _context2.stop();
|
|
270
284
|
}
|
|
271
|
-
}, _callee2, null, [[8,
|
|
285
|
+
}, _callee2, null, [[8, 28]]);
|
|
272
286
|
}));
|
|
273
287
|
return function saveAddress(_x3, _x4) {
|
|
274
288
|
return _ref2.apply(this, arguments);
|
|
@@ -365,7 +365,13 @@ var BusinessAndProductList = exports.BusinessAndProductList = function BusinessA
|
|
|
365
365
|
categoryState.products = productsFiltered || [];
|
|
366
366
|
} else if (categorySelected.id === 'featured') {
|
|
367
367
|
_productsFiltered = businessState === null || businessState === void 0 || (_businessState$busine8 = businessState.business) === null || _businessState$busine8 === void 0 || (_businessState$busine8 = _businessState$busine8.categories) === null || _businessState$busine8 === void 0 ? void 0 : _businessState$busine8.reduce(function (products, category) {
|
|
368
|
-
return [].concat(_toConsumableArray(products), _toConsumableArray(category.products)
|
|
368
|
+
return [].concat(_toConsumableArray(products), _toConsumableArray(category.products.map(function (product) {
|
|
369
|
+
return _objectSpread(_objectSpread({}, product), category.slug ? {
|
|
370
|
+
category: _objectSpread(_objectSpread({}, product === null || product === void 0 ? void 0 : product.category), {}, {
|
|
371
|
+
slug: category.slug
|
|
372
|
+
})
|
|
373
|
+
} : {});
|
|
374
|
+
})));
|
|
369
375
|
}, []).filter(function (product) {
|
|
370
376
|
return isFeaturedSearch(product);
|
|
371
377
|
});
|
|
@@ -381,7 +387,13 @@ var BusinessAndProductList = exports.BusinessAndProductList = function BusinessA
|
|
|
381
387
|
}
|
|
382
388
|
productsToFilter = avoidProductDuplicate ? _categoriesCustom : businessState === null || businessState === void 0 || (_businessState$busine10 = businessState.business) === null || _businessState$busine10 === void 0 ? void 0 : _businessState$busine10.categories;
|
|
383
389
|
_productsFiltered2 = productsToFilter === null || productsToFilter === void 0 ? void 0 : productsToFilter.reduce(function (products, category) {
|
|
384
|
-
return [].concat(_toConsumableArray(products), _toConsumableArray(category.products)
|
|
390
|
+
return [].concat(_toConsumableArray(products), _toConsumableArray(category.products.map(function (product) {
|
|
391
|
+
return _objectSpread(_objectSpread({}, product), category.slug ? {
|
|
392
|
+
category: _objectSpread(_objectSpread({}, product === null || product === void 0 ? void 0 : product.category), {}, {
|
|
393
|
+
slug: category.slug
|
|
394
|
+
})
|
|
395
|
+
} : {});
|
|
396
|
+
})));
|
|
385
397
|
}, []).filter(function (product) {
|
|
386
398
|
return isMatchSearch(product.name, product.description, product === null || product === void 0 ? void 0 : product.price);
|
|
387
399
|
});
|
|
@@ -668,7 +680,14 @@ var BusinessAndProductList = exports.BusinessAndProductList = function BusinessA
|
|
|
668
680
|
}
|
|
669
681
|
if (!(categorySelected.id && categorySelected.id !== 'featured')) {
|
|
670
682
|
productsList = searchValue ? _toConsumableArray(result) : (_ref9 = []).concat.apply(_ref9, _toConsumableArray(result.map(function (category) {
|
|
671
|
-
|
|
683
|
+
var _category$products2;
|
|
684
|
+
return category === null || category === void 0 || (_category$products2 = category.products) === null || _category$products2 === void 0 ? void 0 : _category$products2.map(function (product) {
|
|
685
|
+
return _objectSpread(_objectSpread({}, product), category !== null && category !== void 0 && category.slug ? {
|
|
686
|
+
category: _objectSpread(_objectSpread({}, product.category), {}, {
|
|
687
|
+
slug: category.slug
|
|
688
|
+
})
|
|
689
|
+
} : {});
|
|
690
|
+
});
|
|
672
691
|
}))).filter(function (item) {
|
|
673
692
|
return item;
|
|
674
693
|
});
|
|
@@ -569,7 +569,7 @@ var OrderDetails = exports.OrderDetails = function OrderDetails(props) {
|
|
|
569
569
|
*/
|
|
570
570
|
var getOrder = /*#__PURE__*/function () {
|
|
571
571
|
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
572
|
-
var source, options, _result, result, error, response, res, _yield$ordering$setAc7, content, order, err, businessData,
|
|
572
|
+
var source, options, _result, result, error, response, res, _yield$ordering$setAc7, content, order, err, businessData, _yield$ordering$setAc8, _content, _e$message, _order$id, _e$message2;
|
|
573
573
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
574
574
|
while (1) switch (_context7.prev = _context7.next) {
|
|
575
575
|
case 0:
|
|
@@ -631,7 +631,7 @@ var OrderDetails = exports.OrderDetails = function OrderDetails(props) {
|
|
|
631
631
|
}
|
|
632
632
|
setOrderState(_objectSpread(_objectSpread({}, orderState), {}, {
|
|
633
633
|
loading: false,
|
|
634
|
-
error: [
|
|
634
|
+
error: [err !== null && err !== void 0 ? err : 'ERROR']
|
|
635
635
|
}));
|
|
636
636
|
return _context7.abrupt("return");
|
|
637
637
|
case 30:
|
package/package.json
CHANGED
|
@@ -127,14 +127,22 @@ export const AddressForm = (props) => {
|
|
|
127
127
|
|
|
128
128
|
setFormState({ ...formState, loading: true })
|
|
129
129
|
try {
|
|
130
|
+
const data = { ...values, ...formState.changes }
|
|
131
|
+
Object.keys(data).forEach(key => {
|
|
132
|
+
if (data[key] === null) {
|
|
133
|
+
delete data[key]
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
|
|
130
137
|
const { content } = await ordering
|
|
131
138
|
.users(userByToken?.id || userId)
|
|
132
139
|
.addresses(addressState.address?.id)
|
|
133
|
-
.save(
|
|
140
|
+
.save(data, { accessToken: userByToken?.session?.token || accessToken })
|
|
134
141
|
setFormState({
|
|
135
142
|
...formState,
|
|
136
143
|
loading: false,
|
|
137
144
|
error: content.error ? content.result : null,
|
|
145
|
+
result: content.result,
|
|
138
146
|
changes: content.error ? formState.changes : {}
|
|
139
147
|
})
|
|
140
148
|
if (!content.error) {
|
|
@@ -142,15 +150,15 @@ export const AddressForm = (props) => {
|
|
|
142
150
|
...addressState,
|
|
143
151
|
address: content.result
|
|
144
152
|
})
|
|
145
|
-
onSaveAddress && onSaveAddress(content.result)
|
|
146
153
|
if (isSelectedAfterAdd) {
|
|
147
|
-
changeAddress(content.result.id, {
|
|
154
|
+
await changeAddress(content.result.id, {
|
|
148
155
|
address: isEdit ? null : content.result,
|
|
149
156
|
country_code: content.result?.country_code,
|
|
150
157
|
type: options?.type,
|
|
151
158
|
isEdit
|
|
152
159
|
})
|
|
153
160
|
}
|
|
161
|
+
onSaveAddress && onSaveAddress(content.result)
|
|
154
162
|
}
|
|
155
163
|
if (userCustomerSetup) {
|
|
156
164
|
await setUserCustomer(userCustomerSetup, true)
|
|
@@ -269,7 +269,13 @@ export const BusinessAndProductList = (props) => {
|
|
|
269
269
|
categoryState.products = productsFiltered || []
|
|
270
270
|
} else if (categorySelected.id === 'featured') {
|
|
271
271
|
const productsFiltered = businessState?.business?.categories?.reduce(
|
|
272
|
-
(products, category) => [
|
|
272
|
+
(products, category) => [
|
|
273
|
+
...products,
|
|
274
|
+
...category.products.map(product => ({
|
|
275
|
+
...product,
|
|
276
|
+
...(category.slug ? { category: { ...product?.category, slug: category.slug } } : {})
|
|
277
|
+
}))
|
|
278
|
+
], []
|
|
273
279
|
).filter(
|
|
274
280
|
product => isFeaturedSearch(product)
|
|
275
281
|
)
|
|
@@ -283,7 +289,13 @@ export const BusinessAndProductList = (props) => {
|
|
|
283
289
|
|
|
284
290
|
const productsToFilter = avoidProductDuplicate ? _categoriesCustom : businessState?.business?.categories
|
|
285
291
|
const productsFiltered = productsToFilter?.reduce(
|
|
286
|
-
(products, category) => [
|
|
292
|
+
(products, category) => [
|
|
293
|
+
...products,
|
|
294
|
+
...category.products.map(product => ({
|
|
295
|
+
...product,
|
|
296
|
+
...(category.slug ? { category: { ...product?.category, slug: category.slug } } : {})
|
|
297
|
+
}))
|
|
298
|
+
], []
|
|
287
299
|
).filter(
|
|
288
300
|
product => isMatchSearch(product.name, product.description, product?.price)
|
|
289
301
|
)
|
|
@@ -496,7 +508,14 @@ export const BusinessAndProductList = (props) => {
|
|
|
496
508
|
}
|
|
497
509
|
|
|
498
510
|
if (!(categorySelected.id && categorySelected.id !== 'featured')) {
|
|
499
|
-
const productsList = searchValue
|
|
511
|
+
const productsList = searchValue
|
|
512
|
+
? [...result]
|
|
513
|
+
: [].concat(...result.map(category =>
|
|
514
|
+
category?.products?.map(product => ({
|
|
515
|
+
...product,
|
|
516
|
+
...(category?.slug ? { category: { ...product.category, slug: category.slug } } : {})
|
|
517
|
+
}))
|
|
518
|
+
)).filter(item => item)
|
|
500
519
|
const productsListFeatured = featuredRes?.content?.result ?? []
|
|
501
520
|
const paginationData = categorySelected.id === 'featured'
|
|
502
521
|
? categoriesState?.featured?.pagination ?? {}
|