orderiom-api-package 0.2.43 → 0.2.45

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.2.43",
3
+ "version": "0.2.45",
4
4
  "description": "this package will install all neccessary api calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,22 @@
1
1
  import axios from "axios";
2
2
 
3
+ function calculateBasketIdParameter(isLogin) {
4
+ if(isLogin) return undefined;
5
+ // localStorage might fail
6
+ let baskets = [];
7
+ try{
8
+ baskets = JSON.parse(localStorage.getItem("basket")) || [];
9
+ }catch(e){
10
+ console.error(e);
11
+ throw new Error('Basket not found');
12
+ }
13
+ const foundBasket = baskets.find(basket => basket.restaurantId === restaurantId);
14
+ if(!foundBasket){
15
+ throw new Error('Basket not found');
16
+ }
17
+ return foundBasket.basketId;
18
+ }
19
+
3
20
  const state = () => ({
4
21
  productOrder: null,
5
22
  userOrder: {},
@@ -710,8 +727,14 @@ const actions = {
710
727
  }
711
728
  });
712
729
  },
713
- getShippingPrice({ commit }, data) {
714
-
730
+ getShippingPrice({ commit, rootState }, data) {
731
+ let basketId = undefined;
732
+ try{
733
+ basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken);
734
+ } catch(e) {
735
+ console.error(e);
736
+ return { type: 'error', msg: 'Basket not found' }
737
+ }
715
738
  if (!data.postalCode || !data.deliveryType) {
716
739
  return
717
740
  }
@@ -721,6 +744,7 @@ const actions = {
721
744
  deliveryType: data.deliveryType,
722
745
  postalCode: data.postalCode,
723
746
  restaurantId: data.restaurantId,
747
+ basketId:basketId
724
748
  },
725
749
  })
726
750
  .then((res) => {
@@ -254,7 +254,12 @@ const actions = {
254
254
  return axios
255
255
  .post("api/restaurant/reserve-table", {
256
256
  restaurantId: restaurantId,
257
- tableInfo: data.tableInfo,
257
+ people: data.people,
258
+ date: data.date,
259
+ time: data.time,
260
+ email: data.email,
261
+ name: data.name,
262
+ phone: data.phone,
258
263
  }).then((result) => {
259
264
  commit('setReservedTables', result.data.data);
260
265
  return {