orderiom-api-package 0.3.18 → 0.3.19
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/product.js +10 -1
package/package.json
CHANGED
package/src/modules/product.js
CHANGED
|
@@ -6,6 +6,7 @@ const state = () => ({
|
|
|
6
6
|
selectedTime: null,
|
|
7
7
|
selectedDate: null,
|
|
8
8
|
categories: [],
|
|
9
|
+
subCategoris: [],
|
|
9
10
|
selectedCategory: null,
|
|
10
11
|
products: null,
|
|
11
12
|
selectedProduct: null,
|
|
@@ -118,7 +119,10 @@ const mutations = {
|
|
|
118
119
|
},
|
|
119
120
|
basketLoadedOnce(state){
|
|
120
121
|
state.basketLoadedOnce = true;
|
|
121
|
-
}
|
|
122
|
+
},
|
|
123
|
+
setSubCategories(state , subCategoris){
|
|
124
|
+
state.subCategoris = subCategoris;
|
|
125
|
+
}
|
|
122
126
|
};
|
|
123
127
|
const actions = {
|
|
124
128
|
// TODO: note the axios in loop
|
|
@@ -215,6 +219,7 @@ const actions = {
|
|
|
215
219
|
commit("setSelectedCategory", data.category);
|
|
216
220
|
|
|
217
221
|
let basketId = undefined;
|
|
222
|
+
const subCategoris =[];
|
|
218
223
|
try{
|
|
219
224
|
basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken, data.restaurantId);
|
|
220
225
|
} catch(e) {
|
|
@@ -228,11 +233,15 @@ const actions = {
|
|
|
228
233
|
basketId
|
|
229
234
|
}}).then(res => {
|
|
230
235
|
res.data.data.forEach(productInCategory => {
|
|
236
|
+
if(productInCategory.subcategory_name && !state.subCategoris.includes(productInCategory.subcategory_name)){
|
|
237
|
+
subCategoris.push(productInCategory.subcategory_name)
|
|
238
|
+
}
|
|
231
239
|
productInCategory.quantity = state.ShoppingCart
|
|
232
240
|
.filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
|
|
233
241
|
.reduce((a, b) => a.quantity + b.quantity, 0)
|
|
234
242
|
});
|
|
235
243
|
|
|
244
|
+
commit('setSubCategories' , subCategoris)
|
|
236
245
|
commit("setProduct", res.data.data);
|
|
237
246
|
return { type: 'success', data: res.data.data }
|
|
238
247
|
}).catch(
|