orderiom-api-package 0.3.22 → 0.3.24

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orderiom-api-package",
3
- "version": "0.3.22",
3
+ "version": "0.3.24",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -30,6 +30,23 @@ const state = () => ({
30
30
  changingDeliveryType: false,
31
31
  basketLoadedOnce: false,
32
32
  });
33
+ const getters = {
34
+ subCategories(state){
35
+ if(!state.products) return []
36
+ const subCategories = [];
37
+ const ids = Array.from(new Set(state.products.map(productInCategory=>
38
+ productInCategory.subcategory_id
39
+ )))
40
+
41
+ ids.forEach(id=>{
42
+ let filter = state.products.find(i=> i.subcategory_id === id)
43
+ subCategories.push({name: filter.subcategory_name, id: filter.subcategory_id, imagePath: filter.subcategory_image})
44
+ })
45
+
46
+ return subCategories
47
+
48
+ }
49
+ }
33
50
  const mutations = {
34
51
  setSelectedDate(state, date) {
35
52
  state.selectedDate = date
@@ -219,7 +236,6 @@ const actions = {
219
236
  commit("setSelectedCategory", data.category);
220
237
 
221
238
  let basketId = undefined;
222
- const subCategories =[];
223
239
  try{
224
240
  basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken, data.restaurantId);
225
241
  } catch(e) {
@@ -233,15 +249,10 @@ const actions = {
233
249
  basketId
234
250
  }}).then(res => {
235
251
  res.data.data.forEach(productInCategory => {
236
- if(productInCategory.subcategory_name && !subCategories.includes(productInCategory.subcategory_name) ){
237
- subCategories.push(productInCategory.subcategory_name)
238
- }
239
252
  productInCategory.quantity = state.ShoppingCart
240
253
  .filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
241
254
  .reduce((a, b) => a.quantity + b.quantity, 0)
242
255
  });
243
-
244
- commit('setSubCategories' , subCategories)
245
256
  commit("setProduct", res.data.data);
246
257
  return { type: 'success', data: res.data.data }
247
258
  }).catch(
@@ -405,6 +416,7 @@ const actions = {
405
416
  export default {
406
417
  namespaced: true,
407
418
  state,
419
+ getters,
408
420
  mutations,
409
- actions
410
- };
421
+ actions,
422
+ };