orderiom-api-package
Advanced tools
Comparing version 0.3.28 to 0.3.29
{ | ||
"name": "orderiom-api-package", | ||
"version": "0.3.28", | ||
"version": "0.3.29", | ||
"description": "This package will install all necessary API calls for every orderiom restaurant", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
import axios from "axios"; | ||
import Vue from 'vue'; | ||
import {commonErrorCallback, calculateBasketIdParameter, updateBasket, restaurantIdEnv} from '../common'; | ||
@@ -149,43 +148,44 @@ | ||
getCategoriesWithProducts({ commit, dispatch }, restaurantId) { | ||
return axios | ||
.get("api/restaurant/category", { params: { restaurantId: restaurantId } }) | ||
.then((res) => { | ||
let categories = res.data.data | ||
commit("setSelectedCategory", categories[0]); | ||
axios | ||
.get("api/restaurant/category", { params: { restaurantId: restaurantId, extra: 1 } }) | ||
.then((res) => { | ||
if (res.data.data.length) { | ||
categories = [...categories, ...res.data.data]; | ||
for (let i = 0; i < categories.length; i++) { | ||
const element = categories[i]; | ||
dispatch("getProducts", { | ||
category: element, | ||
restaurantId: restaurantId, | ||
}) | ||
.then((res) => { | ||
Vue.set(element, 'products', res.data); | ||
}); | ||
} | ||
commit('setCategories', categories); | ||
} | ||
else { | ||
commit('setCategories', categories); | ||
for (let i = 0; i < categories.length; i++) { | ||
const element = categories[i]; | ||
dispatch("getProducts", { | ||
category: element, | ||
restaurantId: restaurantId, | ||
}) | ||
.then((res) => { | ||
Vue.set(element, 'products', res.data) | ||
}); | ||
} | ||
} | ||
return axios.get("api/restaurant/category", { | ||
params: { | ||
restaurantId: restaurantId | ||
} | ||
}).then(res => { | ||
let categories = res.data.data | ||
commit("setSelectedCategory", categories[0]); | ||
axios.get("api/restaurant/category", { | ||
params: { | ||
restaurantId: restaurantId, | ||
extra: 1 | ||
} | ||
}).then(res => { | ||
if (res.data.data.length) { | ||
categories = [...categories, ...res.data.data]; | ||
categories.forEach(cat => { | ||
dispatch("getProducts", { | ||
category: cat, | ||
restaurantId: restaurantId, | ||
}).then(res => { | ||
cat.products = res.data; | ||
cat.products.push(); | ||
}); | ||
}); | ||
commit('setCategories', categories); | ||
} else { | ||
commit('setCategories', categories); | ||
categories.forEach(cat => { | ||
dispatch("getProducts", { | ||
category: cat, | ||
restaurantId: restaurantId, | ||
}).then(res => { | ||
cat.products = res.data; | ||
cat.products.push(); | ||
}); | ||
}) | ||
} | ||
}) | ||
.catch( | ||
commonErrorCallback() | ||
); | ||
}).catch( | ||
commonErrorCallback() | ||
); | ||
}, | ||
@@ -192,0 +192,0 @@ getCategories({ commit, dispatch }, restaurantId) { |
95690