orderiom-api-package 0.4.116 → 0.5.0

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.4.116",
3
+ "version": "0.5.0",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -202,6 +202,49 @@ const actions = {
202
202
  if (basketProduct) basketProduct.changingQuantity = false;
203
203
  });
204
204
  },
205
+ addMultipleItemsToBasket({ dispatch, rootState }, data) {
206
+ let basketId = undefined;
207
+ try {
208
+ basketId = calculateBasketIdParameter(data ? data.restaurantId : undefined);
209
+ } catch (e) {
210
+ console.error(e);
211
+ return { type: "error", msg: "Basket not found" };
212
+ }
213
+
214
+ data.items.map(item => {
215
+ item.basketProduct = !item.basketProductId
216
+ ? null
217
+ : rootState.orderiomApiPackage.product.ShoppingCart.find(f => f.basketProductId === item.basketProductId);
218
+ if (item.basketProduct) item.basketProduct.changingQuantity = true;
219
+
220
+ item.quantity = parseInt(item.quantity);
221
+ item.quantity = !item.quantity || item.quantity < 1 ? 1 : item.quantity;
222
+
223
+ item.basketProductId = item.basketProductId ? item.basketProductId : undefined;
224
+ item.attributeItems = item.attributeItems && item.attributeItems.length ? item.attributeItems : undefined;
225
+ item.productAttributeItems = item.productAttributeItems && item.productAttributeItems.length
226
+ ? item.productAttributeItems
227
+ : undefined;
228
+ });
229
+
230
+ $http
231
+ .post("api/basket/add-multiple", {
232
+ restaurantId: data.restaurantId,
233
+ basketId,
234
+ items: data.items
235
+ })
236
+ .then(async () => {
237
+ return await dispatch("shoppingCartUpdateCallback", {
238
+ restaurantId: data.restaurantId,
239
+ });
240
+ })
241
+ .catch(commonErrorCallback())
242
+ .finally(() => {
243
+ data.items.map(item => {
244
+ if (item.basketProduct) item.basketProduct.changingQuantity = false;
245
+ });
246
+ });
247
+ },
205
248
  removeFromBasket({ dispatch, rootState }, data) {
206
249
  const basketProduct =
207
250
  rootState.orderiomApiPackage.product.ShoppingCart.find(