orderiom-api-package 0.4.24 → 0.4.26
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 +31 -11
package/package.json
CHANGED
package/src/modules/product.js
CHANGED
|
@@ -243,7 +243,7 @@ const mutations = {
|
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
245
|
const actions = {
|
|
246
|
-
getCategories({ commit, dispatch, rootState }, restaurantId) {
|
|
246
|
+
getCategories({ commit, dispatch, rootState, state }, restaurantId) {
|
|
247
247
|
let basketId = undefined;
|
|
248
248
|
try {
|
|
249
249
|
basketId = calculateBasketIdParameter(
|
|
@@ -264,25 +264,45 @@ const actions = {
|
|
|
264
264
|
if (res.data.data.length) {
|
|
265
265
|
categories = [...categories, ...res.data.data];
|
|
266
266
|
commit('setCategories', categories);
|
|
267
|
-
|
|
267
|
+
if(categories.length){
|
|
268
|
+
if(!state.selectedCategory) {
|
|
269
|
+
commit("setSelectedCategory", categories[0]);
|
|
270
|
+
}else{
|
|
271
|
+
const catInList = categories.find(cat => cat.id === state.selectedCategory.id);
|
|
272
|
+
if(!catInList || JSON.stringify(state.selectedCategory) !== JSON.stringify(catInList)){
|
|
273
|
+
commit("setSelectedCategory", categories[0]);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
268
278
|
dispatch("getProducts", {
|
|
269
|
-
category:
|
|
270
|
-
restaurantId
|
|
279
|
+
category: state.selectedCategory,
|
|
280
|
+
restaurantId,
|
|
271
281
|
});
|
|
272
282
|
dispatch("getAttributeItems", {
|
|
273
|
-
category:
|
|
274
|
-
restaurantId
|
|
283
|
+
category: state.selectedCategory,
|
|
284
|
+
restaurantId
|
|
275
285
|
});
|
|
276
286
|
} else {
|
|
277
287
|
commit('setCategories', categories);
|
|
278
|
-
|
|
288
|
+
if(categories.length){
|
|
289
|
+
if(!state.selectedCategory) {
|
|
290
|
+
commit("setSelectedCategory", categories[0]);
|
|
291
|
+
}else{
|
|
292
|
+
const catInList = categories.find(cat => cat.id === state.selectedCategory.id);
|
|
293
|
+
if(!catInList || JSON.stringify(state.selectedCategory) !== JSON.stringify(catInList)){
|
|
294
|
+
commit("setSelectedCategory", categories[0]);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
279
299
|
dispatch("getProducts", {
|
|
280
|
-
category:
|
|
281
|
-
restaurantId
|
|
300
|
+
category: state.selectedCategory,
|
|
301
|
+
restaurantId,
|
|
282
302
|
});
|
|
283
303
|
dispatch("getAttributeItems", {
|
|
284
|
-
category:
|
|
285
|
-
restaurantId
|
|
304
|
+
category: state.selectedCategory,
|
|
305
|
+
restaurantId
|
|
286
306
|
});
|
|
287
307
|
}
|
|
288
308
|
});
|