orderiom-api-package
Advanced tools
Comparing version 0.3.17 to 0.3.18
{ | ||
"name": "orderiom-api-package", | ||
"version": "0.3.17", | ||
"version": "0.3.18", | ||
"description": "This package will install all necessary API calls for every orderiom restaurant", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -53,11 +53,3 @@ import axios from "axios"; | ||
const getBasketSuccess = await dispatch("product/getBasket", data.restaurantId, { root: true }); | ||
const getProductsResult = await dispatch( | ||
"product/getProducts", | ||
{ | ||
category: rootState.orderiomApiPackage.product.selectedCategory, | ||
restaurantId: data.restaurantId | ||
}, | ||
{ root: true } | ||
); | ||
if(!getBasketSuccess || getProductsResult.type !== 'success'){ | ||
if(!getBasketSuccess){ | ||
return { | ||
@@ -68,2 +60,3 @@ type: 'error', | ||
} | ||
return { | ||
@@ -110,7 +103,7 @@ type: 'success', | ||
basketData.push({ | ||
restaurantId: restaurantIdEnv, | ||
restaurantId: data.restaurantId || restaurantIdEnv, | ||
basketId: res.data.data.basketId, | ||
}); | ||
localStorage.setItem("basket", JSON.stringify(basketData)); | ||
const result = await dispatch('product/getBasket', restaurantIdEnv, { root: true }) ; | ||
const result = await dispatch('product/getBasket', data.restaurantId || restaurantIdEnv, { root: true }) ; | ||
return { | ||
@@ -734,3 +727,3 @@ type: result ? 'success' : 'error', | ||
}).then(res => | ||
updateBasket({commit, basketId, res, restaurantId: data.restaurantId}) | ||
updateBasket({commit, basketId, res, restaurantId: data ? data.restaurantId : undefined}) | ||
).catch(err => { | ||
@@ -737,0 +730,0 @@ console.error(err); |
@@ -230,32 +230,10 @@ import axios from "axios"; | ||
}}).then(res => { | ||
let products = res.data.data; | ||
products.map(m => { | ||
if (state.ShoppingCart.find( | ||
(p) => p.RestaurantProductId == m.id | ||
)) { | ||
if (!m.is_package) { | ||
Vue.set(m, 'quantity', state.ShoppingCart.find( | ||
(p) => p.RestaurantProductId == m.id | ||
).quantity) | ||
} | ||
else { | ||
const productsInBasket = []; | ||
state.ShoppingCart.map(b => { | ||
if (b.RestaurantProductId == m.id) { | ||
productsInBasket.push( | ||
b.quantity | ||
); | ||
} | ||
}); | ||
let qty = productsInBasket.reduce(function (a, b) { | ||
return a + b; | ||
}, 0); | ||
Vue.set(m, 'quantity', qty) | ||
} | ||
} else { | ||
Vue.set(m, 'quantity', 0) | ||
} | ||
}) | ||
commit("setProduct", products); | ||
return { type: 'success', data: products } | ||
res.data.data.forEach(productInCategory => { | ||
productInCategory.quantity = state.ShoppingCart | ||
.filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id)) | ||
.reduce((a, b) => a.quantity + b.quantity, 0) | ||
}); | ||
commit("setProduct", res.data.data); | ||
return { type: 'success', data: res.data.data } | ||
}).catch( | ||
@@ -280,3 +258,3 @@ commonErrorCallback() | ||
basketId, | ||
restaurantId: restaurantIdEnv | ||
restaurantId: data.restaurantId || restaurantIdEnv | ||
} | ||
@@ -283,0 +261,0 @@ }).then(res => |
@@ -148,3 +148,3 @@ import axios from "axios"; | ||
.post("api/restaurant/reserve-table", { | ||
restaurantId: restaurantIdEnv, | ||
restaurantId: data.restaurantId || restaurantIdEnv, | ||
people: data.people, | ||
@@ -180,7 +180,7 @@ date: data.date, | ||
}, | ||
getBlogsByTag({ commit }, tagId) { | ||
getBlogsByTag({ commit }, tagId, restaurantId = null) { | ||
commit('startFetchingBlogs'); | ||
return axios.get('/api/blogs/by-tag', { | ||
params: { | ||
restaurantId: restaurantIdEnv, | ||
restaurantId: restaurantId || restaurantIdEnv, | ||
tagId | ||
@@ -216,4 +216,4 @@ } | ||
}, | ||
getBlogBySlug({ commit }, blogSlug) { | ||
return axios.get('api/blogs/show/slug', { params: {blogSlug, restaurantId: restaurantIdEnv}}).then(res => { | ||
getBlogBySlug({ commit }, blogSlug, restaurantId = null) { | ||
return axios.get('api/blogs/show/slug', { params: {blogSlug, restaurantId: restaurantId || restaurantIdEnv}}).then(res => { | ||
commit('setBlog', res.data.data); | ||
@@ -220,0 +220,0 @@ return { type: 'success', msg: 'ok' } |
94460
2244