orderiom-api-package 0.3.21 → 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.21",
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,16 +240,10 @@ const actions = {
233
240
  basketId
234
241
  }}).then(res => {
235
242
  res.data.data.forEach(productInCategory => {
236
- console.log(state.subCategories.includes(productInCategory.subcategory_name));
237
- if(productInCategory.subcategory_name && !subCategories.includes(productInCategory.subcategory_name) ){
238
- subCategories.push(productInCategory.subcategory_name)
239
- }
240
243
  productInCategory.quantity = state.ShoppingCart
241
244
  .filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
242
245
  .reduce((a, b) => a.quantity + b.quantity, 0)
243
246
  });
244
-
245
- commit('setSubCategories' , subCategories)
246
247
  commit("setProduct", res.data.data);
247
248
  return { type: 'success', data: res.data.data }
248
249
  }).catch(
@@ -406,6 +407,7 @@ const actions = {
406
407
  export default {
407
408
  namespaced: true,
408
409
  state,
410
+ getters,
409
411
  mutations,
410
- actions
411
- };
412
+ actions,
413
+ };