orderiom-api-package 0.3.17 → 0.3.18
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 +1 -1
- package/src/modules/order.js +5 -12
- package/src/modules/product.js +9 -31
- package/src/modules/restaurant.js +5 -5
package/package.json
CHANGED
package/src/modules/order.js
CHANGED
|
@@ -50,20 +50,13 @@ const mutations = {
|
|
|
50
50
|
const actions = {
|
|
51
51
|
async shoppingCartUpdateCallback({ dispatch, rootState }, data){
|
|
52
52
|
const getBasketSuccess = await dispatch("product/getBasket", data.restaurantId, { root: true });
|
|
53
|
-
|
|
54
|
-
"product/getProducts",
|
|
55
|
-
{
|
|
56
|
-
category: rootState.orderiomApiPackage.product.selectedCategory,
|
|
57
|
-
restaurantId: data.restaurantId
|
|
58
|
-
},
|
|
59
|
-
{ root: true }
|
|
60
|
-
);
|
|
61
|
-
if(!getBasketSuccess || getProductsResult.type !== 'success'){
|
|
53
|
+
if(!getBasketSuccess){
|
|
62
54
|
return {
|
|
63
55
|
type: 'error',
|
|
64
56
|
msg: 'There was an error in fetching the basket and products'
|
|
65
57
|
}
|
|
66
58
|
}
|
|
59
|
+
|
|
67
60
|
return {
|
|
68
61
|
type: 'success',
|
|
69
62
|
msg: ''
|
|
@@ -105,11 +98,11 @@ const actions = {
|
|
|
105
98
|
.post("api/order/create-basket", data)
|
|
106
99
|
.then(async res => {
|
|
107
100
|
basketData.push({
|
|
108
|
-
restaurantId: restaurantIdEnv,
|
|
101
|
+
restaurantId: data.restaurantId || restaurantIdEnv,
|
|
109
102
|
basketId: res.data.data.basketId,
|
|
110
103
|
});
|
|
111
104
|
localStorage.setItem("basket", JSON.stringify(basketData));
|
|
112
|
-
const result = await dispatch('product/getBasket', restaurantIdEnv, { root: true }) ;
|
|
105
|
+
const result = await dispatch('product/getBasket', data.restaurantId || restaurantIdEnv, { root: true }) ;
|
|
113
106
|
return {
|
|
114
107
|
type: result ? 'success' : 'error',
|
|
115
108
|
msg: result ? 'Basket created' : 'There was an error in fetching the basket info',
|
|
@@ -728,7 +721,7 @@ const actions = {
|
|
|
728
721
|
restaurantId: data.restaurantId || restaurantIdEnv,
|
|
729
722
|
...data
|
|
730
723
|
}).then(res =>
|
|
731
|
-
updateBasket({commit, basketId, res, restaurantId: data.restaurantId})
|
|
724
|
+
updateBasket({commit, basketId, res, restaurantId: data ? data.restaurantId : undefined})
|
|
732
725
|
).catch(err => {
|
|
733
726
|
console.error(err);
|
|
734
727
|
return false;
|
package/src/modules/product.js
CHANGED
|
@@ -227,36 +227,14 @@ const actions = {
|
|
|
227
227
|
restaurantId: data.restaurantId,
|
|
228
228
|
basketId
|
|
229
229
|
}}).then(res => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
).quantity)
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
const productsInBasket = [];
|
|
242
|
-
state.ShoppingCart.map(b => {
|
|
243
|
-
if (b.RestaurantProductId == m.id) {
|
|
244
|
-
productsInBasket.push(
|
|
245
|
-
b.quantity
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
let qty = productsInBasket.reduce(function (a, b) {
|
|
250
|
-
return a + b;
|
|
251
|
-
}, 0);
|
|
252
|
-
Vue.set(m, 'quantity', qty)
|
|
253
|
-
}
|
|
254
|
-
} else {
|
|
255
|
-
Vue.set(m, 'quantity', 0)
|
|
256
|
-
}
|
|
257
|
-
})
|
|
258
|
-
commit("setProduct", products);
|
|
259
|
-
return { type: 'success', data: products }
|
|
230
|
+
res.data.data.forEach(productInCategory => {
|
|
231
|
+
productInCategory.quantity = state.ShoppingCart
|
|
232
|
+
.filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
|
|
233
|
+
.reduce((a, b) => a.quantity + b.quantity, 0)
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
commit("setProduct", res.data.data);
|
|
237
|
+
return { type: 'success', data: res.data.data }
|
|
260
238
|
}).catch(
|
|
261
239
|
commonErrorCallback()
|
|
262
240
|
);
|
|
@@ -276,7 +254,7 @@ const actions = {
|
|
|
276
254
|
return axios.get('api/basket', {
|
|
277
255
|
params: {
|
|
278
256
|
basketId,
|
|
279
|
-
restaurantId: restaurantIdEnv
|
|
257
|
+
restaurantId: data.restaurantId || restaurantIdEnv
|
|
280
258
|
}
|
|
281
259
|
}).then(res =>
|
|
282
260
|
updateBasket({commit, basketId, res, restaurantId: data ? data.restaurantId : undefined})
|
|
@@ -145,7 +145,7 @@ const actions = {
|
|
|
145
145
|
addReservedTables({ commit }, data) {
|
|
146
146
|
return axios
|
|
147
147
|
.post("api/restaurant/reserve-table", {
|
|
148
|
-
restaurantId: restaurantIdEnv,
|
|
148
|
+
restaurantId: data.restaurantId || restaurantIdEnv,
|
|
149
149
|
people: data.people,
|
|
150
150
|
date: data.date,
|
|
151
151
|
time: data.time,
|
|
@@ -176,11 +176,11 @@ const actions = {
|
|
|
176
176
|
return commonErrorCallback()(error);
|
|
177
177
|
})
|
|
178
178
|
},
|
|
179
|
-
getBlogsByTag({ commit }, tagId) {
|
|
179
|
+
getBlogsByTag({ commit }, tagId, restaurantId = null) {
|
|
180
180
|
commit('startFetchingBlogs');
|
|
181
181
|
return axios.get('/api/blogs/by-tag', {
|
|
182
182
|
params: {
|
|
183
|
-
restaurantId: restaurantIdEnv,
|
|
183
|
+
restaurantId: restaurantId || restaurantIdEnv,
|
|
184
184
|
tagId
|
|
185
185
|
}
|
|
186
186
|
}).then(res => {
|
|
@@ -211,8 +211,8 @@ const actions = {
|
|
|
211
211
|
return commonErrorCallback()(error);
|
|
212
212
|
})
|
|
213
213
|
},
|
|
214
|
-
getBlogBySlug({ commit }, blogSlug) {
|
|
215
|
-
return axios.get('api/blogs/show/slug', { params: {blogSlug, restaurantId: restaurantIdEnv}}).then(res => {
|
|
214
|
+
getBlogBySlug({ commit }, blogSlug, restaurantId = null) {
|
|
215
|
+
return axios.get('api/blogs/show/slug', { params: {blogSlug, restaurantId: restaurantId || restaurantIdEnv}}).then(res => {
|
|
216
216
|
commit('setBlog', res.data.data);
|
|
217
217
|
return { type: 'success', msg: 'ok' }
|
|
218
218
|
}).catch(error => {
|