orderiom-api-package 0.4.106 → 0.4.108
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/package.json +1 -1
- package/src/modules/order.js +4 -4
- package/src/modules/product.js +62 -2
package/package.json
CHANGED
package/src/modules/order.js
CHANGED
|
@@ -602,11 +602,11 @@ const actions = {
|
|
|
602
602
|
result[element[0]] = element[1];
|
|
603
603
|
return result;
|
|
604
604
|
}, {}),
|
|
605
|
+
}).then(() => {
|
|
606
|
+
commit("product/SetShoppingCart", [], {root: true});
|
|
607
|
+
commit("product/setBasketInfo", {}, {root: true});
|
|
608
|
+
commit("product/setDeliveryTime", "", {root: true});
|
|
605
609
|
});
|
|
606
|
-
|
|
607
|
-
commit("product/SetShoppingCart", [], {root: true});
|
|
608
|
-
commit("product/setBasketInfo", {}, {root: true});
|
|
609
|
-
commit("product/setDeliveryTime", "", {root: true});
|
|
610
610
|
}).catch(error => {
|
|
611
611
|
const status = error.response ? error.response.status : null;
|
|
612
612
|
if (status === 422) {
|
package/src/modules/product.js
CHANGED
|
@@ -24,6 +24,8 @@ const state = () => ({
|
|
|
24
24
|
fetchingBasket: false,
|
|
25
25
|
changingDeliveryType: false,
|
|
26
26
|
basketLoadedOnce: false,
|
|
27
|
+
searchedProducts: null,
|
|
28
|
+
showSearchedProducts: false,
|
|
27
29
|
pinnedProducts: null,
|
|
28
30
|
showPinnedProducts: false,
|
|
29
31
|
fetchingProducts: false,
|
|
@@ -31,13 +33,19 @@ const state = () => ({
|
|
|
31
33
|
pinnedProductsFetchedOnce: false,
|
|
32
34
|
fetchingProductsHappyHour: false,
|
|
33
35
|
});
|
|
36
|
+
|
|
37
|
+
function selectedCategoryIsNull(state) {
|
|
38
|
+
return (state.pinnedProducts && state.pinnedProducts.length) ||
|
|
39
|
+
(state.searchedProducts && state.searchedProducts.length);
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
const getters = {
|
|
35
43
|
fetchingProducts(state){
|
|
36
44
|
return !!state.fetchingProducts;
|
|
37
45
|
},
|
|
38
46
|
subCategories(state){
|
|
39
|
-
if(state.showPinnedProducts) {
|
|
40
|
-
if(state
|
|
47
|
+
if(state.showPinnedProducts || state.showSearchedProducts) {
|
|
48
|
+
if(selectedCategoryIsNull(state)){
|
|
41
49
|
return [{
|
|
42
50
|
id: null,
|
|
43
51
|
imagePath:null,
|
|
@@ -189,6 +197,12 @@ const mutations = {
|
|
|
189
197
|
setProduct(state, product) {
|
|
190
198
|
state.products = product
|
|
191
199
|
},
|
|
200
|
+
setSearchedProducts(state, products) {
|
|
201
|
+
state.searchedProducts = products
|
|
202
|
+
},
|
|
203
|
+
setShowSearchedProducts(state, show) {
|
|
204
|
+
state.showSearchedProducts = show;
|
|
205
|
+
},
|
|
192
206
|
setPinnedProducts(state, products) {
|
|
193
207
|
state.pinnedProducts = products
|
|
194
208
|
},
|
|
@@ -369,6 +383,52 @@ const actions = {
|
|
|
369
383
|
commit('setFetchingProducts', false);
|
|
370
384
|
});
|
|
371
385
|
},
|
|
386
|
+
searchProducts({ commit, state, dispatch, rootState }, data) {
|
|
387
|
+
let basketId = undefined;
|
|
388
|
+
try {
|
|
389
|
+
basketId = calculateBasketIdParameter(data ? data.restaurantId : undefined);
|
|
390
|
+
} catch(e) {
|
|
391
|
+
console.error("Search Products: " + e);
|
|
392
|
+
}
|
|
393
|
+
commit('setFetchingProducts', true);
|
|
394
|
+
return $http.get("api/restaurant/search-products", {
|
|
395
|
+
params: {
|
|
396
|
+
restaurantId: data ? data.restaurantId : undefined,
|
|
397
|
+
basketId: basketId,
|
|
398
|
+
name: data ? data.name : undefined
|
|
399
|
+
}
|
|
400
|
+
}).then(res => {
|
|
401
|
+
if (res.status !== 200) {
|
|
402
|
+
commit("setShowSearchedProducts", false);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
res.data.data.forEach(productInCategory => {
|
|
406
|
+
productInCategory.happyHours = [];
|
|
407
|
+
|
|
408
|
+
let quantity = 0;
|
|
409
|
+
state.ShoppingCart
|
|
410
|
+
.filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
|
|
411
|
+
.forEach((item) => quantity += item.quantity);
|
|
412
|
+
productInCategory.quantity = quantity;
|
|
413
|
+
productInCategory.subcategory_id = null;
|
|
414
|
+
});
|
|
415
|
+
commit("setAttributeItems", []);
|
|
416
|
+
commit("setSelectedCategory", null);
|
|
417
|
+
commit("setSearchedProducts", res.data.data);
|
|
418
|
+
commit("setShowSearchedProducts", true);
|
|
419
|
+
commit("setSubCategories", []);
|
|
420
|
+
|
|
421
|
+
if(rootState.orderiomApiPackage.restaurant.restaurantInfo.ignore_pre_order_timing_by_display){
|
|
422
|
+
dispatch('getProductsHappyHourTime');
|
|
423
|
+
}
|
|
424
|
+
return { ...res, data: res.data.data }
|
|
425
|
+
}).catch(
|
|
426
|
+
commonErrorCallback()
|
|
427
|
+
).finally(() => {
|
|
428
|
+
commit('setPinnedProductsFetchedOnce');
|
|
429
|
+
commit('setFetchingProducts', false);
|
|
430
|
+
});
|
|
431
|
+
},
|
|
372
432
|
getPinnedProducts({ commit, state, dispatch, rootState }, data) {
|
|
373
433
|
let basketId = undefined;
|
|
374
434
|
try {
|