orderiom-api-package 0.3.18 → 0.3.20

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.3.18",
3
+ "version": "0.3.20",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -395,7 +395,24 @@ const actions = {
395
395
  // commit('setorder', res.data.data.order)
396
396
  // commit('setuserOrder', JSON.parse(res.data.data.order.user_details));
397
397
  // commit('setshippigPriceOrder', res.data.data.order.shipping_price);
398
- window.location = res.data.data.paymentLink;
398
+
399
+ if(!data.$router || !data.routeName){
400
+ window.location = res.data.data.paymentLink;
401
+ }else{
402
+ data.$router.push({
403
+ name: data.routeName,
404
+ query: res.data.data.paymentLink
405
+ .split('?')[1]
406
+ .split('&')
407
+ .map(query => query.split('='))
408
+ .reduce((result, element) => {
409
+ if(!element) return result;
410
+ result[element[0]] = element[1];
411
+ return result;
412
+ }, {})
413
+ });
414
+ }
415
+
399
416
  var index = data.basket ? basketData.indexOf(basketData.find((item) => item.basketId == data.basket)) :
400
417
  basketData.indexOf(basketData.find((item) => item.restaurantId == data.restaurantId));
401
418
  if (index > -1) {
@@ -6,6 +6,7 @@ const state = () => ({
6
6
  selectedTime: null,
7
7
  selectedDate: null,
8
8
  categories: [],
9
+ subCategoris: [],
9
10
  selectedCategory: null,
10
11
  products: null,
11
12
  selectedProduct: null,
@@ -118,7 +119,10 @@ const mutations = {
118
119
  },
119
120
  basketLoadedOnce(state){
120
121
  state.basketLoadedOnce = true;
121
- }
122
+ },
123
+ setSubCategories(state , subCategoris){
124
+ state.subCategoris = subCategoris;
125
+ }
122
126
  };
123
127
  const actions = {
124
128
  // TODO: note the axios in loop
@@ -215,6 +219,7 @@ const actions = {
215
219
  commit("setSelectedCategory", data.category);
216
220
 
217
221
  let basketId = undefined;
222
+ const subCategoris =[];
218
223
  try{
219
224
  basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken, data.restaurantId);
220
225
  } catch(e) {
@@ -228,11 +233,15 @@ const actions = {
228
233
  basketId
229
234
  }}).then(res => {
230
235
  res.data.data.forEach(productInCategory => {
236
+ if(productInCategory.subcategory_name && !state.subCategoris.includes(productInCategory.subcategory_name)){
237
+ subCategoris.push(productInCategory.subcategory_name)
238
+ }
231
239
  productInCategory.quantity = state.ShoppingCart
232
240
  .filter(itemInCart => Number(itemInCart.RestaurantProductId) === Number(productInCategory.id))
233
241
  .reduce((a, b) => a.quantity + b.quantity, 0)
234
242
  });
235
243
 
244
+ commit('setSubCategories' , subCategoris)
236
245
  commit("setProduct", res.data.data);
237
246
  return { type: 'success', data: res.data.data }
238
247
  }).catch(