orderiom-api-package 0.2.37 → 0.2.39
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/product.js +50 -50
package/package.json
CHANGED
package/src/modules/product.js
CHANGED
|
@@ -232,61 +232,61 @@ const actions = {
|
|
|
232
232
|
},
|
|
233
233
|
getProducts({ commit, state }, data) {
|
|
234
234
|
commit("setSelectedCategory", data.category);
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
productsInBasket.push(
|
|
253
|
-
b.quantity
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
let qty = productsInBasket.reduce(function (a, b) {
|
|
258
|
-
return a + b;
|
|
259
|
-
}, 0);
|
|
260
|
-
Vue.set(m, 'quantity', qty)
|
|
261
|
-
}
|
|
262
|
-
} else {
|
|
263
|
-
Vue.set(m, 'quantity', 0)
|
|
235
|
+
|
|
236
|
+
const params = {
|
|
237
|
+
categoryId: data.category.id,
|
|
238
|
+
restaurantId: data.restaurantId,
|
|
239
|
+
};
|
|
240
|
+
if(data.deliveryType) params.deliveryType = data.deliveryType;
|
|
241
|
+
|
|
242
|
+
return axios.get("api/restaurant/products", { params }).then(res => {
|
|
243
|
+
let products = res.data.data;
|
|
244
|
+
products.map(m => {
|
|
245
|
+
if (state.ShoppingCart.find(
|
|
246
|
+
(p) => p.RestaurantProductId == m.id
|
|
247
|
+
)) {
|
|
248
|
+
if (!m.is_package) {
|
|
249
|
+
Vue.set(m, 'quantity', state.ShoppingCart.find(
|
|
250
|
+
(p) => p.RestaurantProductId == m.id
|
|
251
|
+
).quantity)
|
|
264
252
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
253
|
+
else {
|
|
254
|
+
const productsInBasket = [];
|
|
255
|
+
state.ShoppingCart.map(b => {
|
|
256
|
+
if (b.RestaurantProductId == m.id) {
|
|
257
|
+
productsInBasket.push(
|
|
258
|
+
b.quantity
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
let qty = productsInBasket.reduce(function (a, b) {
|
|
263
|
+
return a + b;
|
|
264
|
+
}, 0);
|
|
265
|
+
Vue.set(m, 'quantity', qty)
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
Vue.set(m, 'quantity', 0)
|
|
270
269
|
}
|
|
271
270
|
})
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
type: 'error',
|
|
277
|
-
msg: Object.values(error.response.data.error.validation).map(m => { return m[0] }).toString()
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if (error.response.status == 401 || error.response.status == 403 || error.response.status == 404 || error.response.status == 400) {
|
|
281
|
-
|
|
282
|
-
return {
|
|
283
|
-
type: 'error',
|
|
284
|
-
msg: error.response.data.message.body
|
|
285
|
-
}
|
|
286
|
-
}
|
|
271
|
+
commit("setProduct", products);
|
|
272
|
+
return { type: 'success', data: products }
|
|
273
|
+
}).catch(error => {
|
|
274
|
+
if(!error.response) return;
|
|
287
275
|
|
|
276
|
+
const status = error.response.status;
|
|
277
|
+
if (status === 422) {
|
|
278
|
+
return {
|
|
279
|
+
type: 'error',
|
|
280
|
+
msg: Object.values(error.response.data.error.validation).map(m => { return m[0] }).toString()
|
|
288
281
|
}
|
|
289
|
-
}
|
|
282
|
+
}
|
|
283
|
+
if ([401, 403, 404, 400].includes(status)) {
|
|
284
|
+
return {
|
|
285
|
+
type: 'error',
|
|
286
|
+
msg: error.response.data.message.body
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
290
|
},
|
|
291
291
|
getBasket({ commit, rootState }, restaurantId) {
|
|
292
292
|
const basket = JSON.parse(localStorage.getItem("basket"));
|