orderiom-api-package 0.3.22 → 0.3.23

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.23",
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,14 @@ const state = () => ({
30
30
  changingDeliveryType: false,
31
31
  basketLoadedOnce: false,
32
32
  });
33
+ const getters = {
34
+ subCategories(state){
35
+ if(!state.products) return []
36
+ return Array.from(new Set(state.products.map(productInCategory =>
37
+ productInCategory.subcategory_name || 'uncategorised'
38
+ )))
39
+ }
40
+ }
33
41
  const mutations = {
34
42
  setSelectedDate(state, date) {
35
43
  state.selectedDate = date
@@ -219,7 +227,6 @@ const actions = {
219
227
  commit("setSelectedCategory", data.category);
220
228
 
221
229
  let basketId = undefined;
222
- const subCategories =[];
223
230
  try{
224
231
  basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken, data.restaurantId);
225
232
  } catch(e) {
@@ -233,15 +240,10 @@ const actions = {
233
240
  basketId
234
241
  }}).then(res => {
235
242
  res.data.data.forEach(productInCategory => {
236
- if(productInCategory.subcategory_name && !subCategories.includes(productInCategory.subcategory_name) ){
237
- subCategories.push(productInCategory.subcategory_name)
238
- }
239
243
  productInCategory.quantity = state.ShoppingCart
240
244
  .filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
241
245
  .reduce((a, b) => a.quantity + b.quantity, 0)
242
246
  });
243
-
244
- commit('setSubCategories' , subCategories)
245
247
  commit("setProduct", res.data.data);
246
248
  return { type: 'success', data: res.data.data }
247
249
  }).catch(
@@ -405,6 +407,7 @@ const actions = {
405
407
  export default {
406
408
  namespaced: true,
407
409
  state,
410
+ getters,
408
411
  mutations,
409
- actions
410
- };
412
+ actions,
413
+ };