orderiom-api-package 0.3.29 → 0.3.30
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/index.js +5 -2
- package/package.json +1 -1
- package/src/common.js +43 -0
- package/src/modules/auth.js +19 -20
- package/src/modules/manager.js +6 -6
- package/src/modules/order.js +27 -28
- package/src/modules/product.js +13 -14
- package/src/modules/restaurant.js +14 -15
package/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import apiStore from './src';
|
|
2
2
|
import enMsg from "./src/messages/en-api.json";
|
|
3
|
-
import deMsg from "./src/messages/de-api.json"
|
|
3
|
+
import deMsg from "./src/messages/de-api.json";
|
|
4
|
+
import {$http} from './src/common';
|
|
5
|
+
|
|
4
6
|
function install(Vue, options = {}, config = {}) {
|
|
5
7
|
if (!options.store) console.log('Please provide a store!!');
|
|
6
8
|
options.store.registerModule('orderiomApiPackage', apiStore, { preserveState: config.preserveState })
|
|
@@ -9,5 +11,6 @@ export default {
|
|
|
9
11
|
install,
|
|
10
12
|
enMsg,
|
|
11
13
|
deMsg,
|
|
12
|
-
modules: apiStore.modules
|
|
14
|
+
modules: apiStore.modules,
|
|
15
|
+
$http
|
|
13
16
|
}
|
package/package.json
CHANGED
package/src/common.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
|
|
1
3
|
export const restaurantIdEnv = process.env.VUE_APP_RESTAURANT_ID ? parseInt(process.env.VUE_APP_RESTAURANT_ID) : null;
|
|
2
4
|
|
|
3
5
|
export function commonErrorCallback(unknownErrorMessage = 'Something went wrong'){
|
|
@@ -71,3 +73,44 @@ export function updateBasket({commit, basketId, res, restaurantId}){
|
|
|
71
73
|
commit(`product/basketLoadedOnce`, null, { root: true });
|
|
72
74
|
return true;
|
|
73
75
|
}
|
|
76
|
+
|
|
77
|
+
axios.defaults.baseURL = process.env.VUE_APP_BASE_API_URL;
|
|
78
|
+
axios.interceptors.request.use(config => {
|
|
79
|
+
const token = localStorage.getItem("privateToken") || localStorage.getItem("publicToken");
|
|
80
|
+
if (token) config.headers["Authorization"] = `Bearer ${token}`;
|
|
81
|
+
return config;
|
|
82
|
+
}, error => {
|
|
83
|
+
return Promise.reject(error);
|
|
84
|
+
});
|
|
85
|
+
axios.interceptors.response.use(response => {
|
|
86
|
+
return response;
|
|
87
|
+
}, error => {
|
|
88
|
+
if (error.response?.data?.error?.validation) {
|
|
89
|
+
const validation = error.response.data.error.validation;
|
|
90
|
+
|
|
91
|
+
if (
|
|
92
|
+
(
|
|
93
|
+
Object.keys(validation).includes("basketId") &&
|
|
94
|
+
validation["basketId"][0] === "basket_does_not_exists"
|
|
95
|
+
) ||
|
|
96
|
+
(
|
|
97
|
+
Object.keys(validation).includes("restaurantId") &&
|
|
98
|
+
validation["restaurantId"][0] === "basket_does_not_exists"
|
|
99
|
+
)
|
|
100
|
+
) {
|
|
101
|
+
localStorage.removeItem("basket");
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (
|
|
106
|
+
error.response?.data?.message?.body === "unauthenticated" &&
|
|
107
|
+
localStorage.getItem("privateToken")
|
|
108
|
+
) {
|
|
109
|
+
localStorage.clear();
|
|
110
|
+
window.location.reload();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return Promise.reject(error);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
export const $http = axios;
|
package/src/modules/auth.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { commonErrorCallback } from '../common';
|
|
1
|
+
import { commonErrorCallback, $http } from '../common';
|
|
3
2
|
|
|
4
3
|
const state = {
|
|
5
4
|
publicToken: null,
|
|
@@ -54,7 +53,7 @@ const mutations = {
|
|
|
54
53
|
};
|
|
55
54
|
const actions = {
|
|
56
55
|
auth({ commit }) {
|
|
57
|
-
return
|
|
56
|
+
return $http
|
|
58
57
|
.post("api/oauth/token", {
|
|
59
58
|
grant_type: process.env.VUE_APP_GRANT_TYPE,
|
|
60
59
|
client_id: process.env.VUE_APP_CLIENT_ID,
|
|
@@ -74,7 +73,7 @@ const actions = {
|
|
|
74
73
|
delete data.restaurantId;
|
|
75
74
|
delete data.ordermood
|
|
76
75
|
}
|
|
77
|
-
return
|
|
76
|
+
return $http
|
|
78
77
|
.post(`api/auth/login`, null, { params: data })
|
|
79
78
|
.then(res => {
|
|
80
79
|
if (authData.manager) {
|
|
@@ -120,7 +119,7 @@ const actions = {
|
|
|
120
119
|
delete data.restaurantId;
|
|
121
120
|
delete authData.ordermood
|
|
122
121
|
}
|
|
123
|
-
return
|
|
122
|
+
return $http
|
|
124
123
|
.post(
|
|
125
124
|
`api/auth/signup`, null, {
|
|
126
125
|
params: data
|
|
@@ -167,7 +166,7 @@ const actions = {
|
|
|
167
166
|
if (!state.privateToken) {
|
|
168
167
|
return;
|
|
169
168
|
}
|
|
170
|
-
return
|
|
169
|
+
return $http
|
|
171
170
|
.get("api/auth/logout", {
|
|
172
171
|
params: {
|
|
173
172
|
...restaurantId
|
|
@@ -189,7 +188,7 @@ const actions = {
|
|
|
189
188
|
if (!state.privateToken) {
|
|
190
189
|
return;
|
|
191
190
|
}
|
|
192
|
-
return
|
|
191
|
+
return $http
|
|
193
192
|
.get("api/auth/user")
|
|
194
193
|
.then(res => {
|
|
195
194
|
const user = res.data.data;
|
|
@@ -206,7 +205,7 @@ const actions = {
|
|
|
206
205
|
basket.find((basket) => basket.restaurantId == restaurantId).basketId
|
|
207
206
|
: ''
|
|
208
207
|
if (basketId)
|
|
209
|
-
|
|
208
|
+
$http
|
|
210
209
|
.post(`api/basket/assign-basket`, null, { params: { basketId: basketId, restaurantId: restaurantId } })
|
|
211
210
|
.then(() => {
|
|
212
211
|
dispatch('product/getBasket', restaurantId, { root: true })
|
|
@@ -222,7 +221,7 @@ const actions = {
|
|
|
222
221
|
basket.find((basket) => basket.restaurantId == restaurantId).basketId
|
|
223
222
|
: ''
|
|
224
223
|
if (basketId)
|
|
225
|
-
|
|
224
|
+
$http
|
|
226
225
|
.post(`api/basket/unassigned-basket`, null, { params: { basketId: basketId } })
|
|
227
226
|
.then(() => {
|
|
228
227
|
return {
|
|
@@ -239,7 +238,7 @@ const actions = {
|
|
|
239
238
|
if (!basket.length) return
|
|
240
239
|
let baskets = basket.map(m => m.basketId)
|
|
241
240
|
for (let i = 0; i < baskets.length; i++) {
|
|
242
|
-
|
|
241
|
+
$http
|
|
243
242
|
.post(`api/basket/unassigned-basket`, null, { params: { basketId: baskets[i] } })
|
|
244
243
|
.then(() => {
|
|
245
244
|
return {
|
|
@@ -254,7 +253,7 @@ const actions = {
|
|
|
254
253
|
}
|
|
255
254
|
},
|
|
256
255
|
restaurantInfo({ commit }, restaurantId) {
|
|
257
|
-
return
|
|
256
|
+
return $http
|
|
258
257
|
.get("api/restaurant/restaurant-by-id", {
|
|
259
258
|
params: {
|
|
260
259
|
restaurantId: restaurantId
|
|
@@ -268,7 +267,7 @@ const actions = {
|
|
|
268
267
|
);
|
|
269
268
|
},
|
|
270
269
|
userUpdate({ dispatch }, userData) {
|
|
271
|
-
return
|
|
270
|
+
return $http
|
|
272
271
|
.post("api/auth/user/update", {
|
|
273
272
|
params: {
|
|
274
273
|
userData,
|
|
@@ -287,7 +286,7 @@ const actions = {
|
|
|
287
286
|
email: data.email,
|
|
288
287
|
restaurantId: data.restaurantId
|
|
289
288
|
} : { email: data };
|
|
290
|
-
return
|
|
289
|
+
return $http
|
|
291
290
|
.post("api/auth/forgot-password", formData)
|
|
292
291
|
.then((res) => {
|
|
293
292
|
dispatch("fetchUser");
|
|
@@ -301,7 +300,7 @@ const actions = {
|
|
|
301
300
|
);
|
|
302
301
|
},
|
|
303
302
|
checkToken({ commit }, token) {
|
|
304
|
-
return
|
|
303
|
+
return $http
|
|
305
304
|
.get(`api/auth/password/reset`, { params: { token: token } })
|
|
306
305
|
.then((res) => {
|
|
307
306
|
commit('setEmail', res.data.data.email);
|
|
@@ -315,7 +314,7 @@ const actions = {
|
|
|
315
314
|
);
|
|
316
315
|
},
|
|
317
316
|
resetPassword({ }, data) {
|
|
318
|
-
return
|
|
317
|
+
return $http
|
|
319
318
|
.post("api/auth/password/reset-password", {
|
|
320
319
|
email: data.email,
|
|
321
320
|
token: data.token,
|
|
@@ -336,7 +335,7 @@ const actions = {
|
|
|
336
335
|
|
|
337
336
|
},
|
|
338
337
|
update({ commit }, userData) {
|
|
339
|
-
return
|
|
338
|
+
return $http.post('api/auth/user/update', null, {
|
|
340
339
|
params: userData
|
|
341
340
|
}).then(result => {
|
|
342
341
|
commit('updateUser', {
|
|
@@ -352,7 +351,7 @@ const actions = {
|
|
|
352
351
|
);
|
|
353
352
|
},
|
|
354
353
|
getUserAddress({ commit }) {
|
|
355
|
-
return
|
|
354
|
+
return $http.get('api/auth/user/address').then((res) => {
|
|
356
355
|
commit('setUserAddress', res.data.data);
|
|
357
356
|
return {
|
|
358
357
|
type: 'success',
|
|
@@ -363,7 +362,7 @@ const actions = {
|
|
|
363
362
|
);
|
|
364
363
|
},
|
|
365
364
|
addUserAddress({ dispatch }, data) {
|
|
366
|
-
return
|
|
365
|
+
return $http.post('api/auth/user/address/add', null, { params: data }).then((res) => {
|
|
367
366
|
dispatch('getUserAddress')
|
|
368
367
|
return {
|
|
369
368
|
type: 'success',
|
|
@@ -374,7 +373,7 @@ const actions = {
|
|
|
374
373
|
);
|
|
375
374
|
},
|
|
376
375
|
removeUserAddress({ dispatch }, id) {
|
|
377
|
-
return
|
|
376
|
+
return $http.put('api/auth/user/address/remove', null, { params: { id } }).then((res) => {
|
|
378
377
|
dispatch('getUserAddress')
|
|
379
378
|
return {
|
|
380
379
|
type: 'success',
|
|
@@ -385,7 +384,7 @@ const actions = {
|
|
|
385
384
|
);
|
|
386
385
|
},
|
|
387
386
|
editUserAddress({ dispatch }, data) {
|
|
388
|
-
return
|
|
387
|
+
return $http.post('api/auth/user/address/edit', null, { params: data }).then((res) => {
|
|
389
388
|
dispatch('getUserAddress')
|
|
390
389
|
return {
|
|
391
390
|
type: 'success',
|
package/src/modules/manager.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {$http} from '../common';
|
|
2
2
|
|
|
3
3
|
const state = () => {
|
|
4
4
|
return {
|
|
@@ -18,12 +18,12 @@ const mutations = {
|
|
|
18
18
|
|
|
19
19
|
const actions = {
|
|
20
20
|
getRestaurantInfo({ commit }) {
|
|
21
|
-
return
|
|
21
|
+
return $http.get("api/managers/restaurant").then((result) => {
|
|
22
22
|
commit("setRestaurantInfo", result.data.data[0]);
|
|
23
23
|
});
|
|
24
24
|
},
|
|
25
25
|
getOrders({ commit }, {dateFrom,dateTo,filterType,restaurantId}) {
|
|
26
|
-
return
|
|
26
|
+
return $http
|
|
27
27
|
.get("api/managers/order", {
|
|
28
28
|
params: {
|
|
29
29
|
from_date:dateFrom,
|
|
@@ -45,7 +45,7 @@ const actions = {
|
|
|
45
45
|
status: data.status,
|
|
46
46
|
restaurantId: data.restaurantId,
|
|
47
47
|
};
|
|
48
|
-
return
|
|
48
|
+
return $http
|
|
49
49
|
.post(
|
|
50
50
|
`api/managers/order/change-status`,
|
|
51
51
|
|
|
@@ -59,7 +59,7 @@ const actions = {
|
|
|
59
59
|
});
|
|
60
60
|
},
|
|
61
61
|
getOrdersPerMinute({},{startTime,endTime,filterType,id} ) {
|
|
62
|
-
return
|
|
62
|
+
return $http
|
|
63
63
|
.get("api/managers/order", {
|
|
64
64
|
params: {
|
|
65
65
|
from_date: startTime,
|
|
@@ -76,7 +76,7 @@ const actions = {
|
|
|
76
76
|
});
|
|
77
77
|
},
|
|
78
78
|
updateOrders({}, id) {
|
|
79
|
-
return
|
|
79
|
+
return $http
|
|
80
80
|
.get("api/order", {
|
|
81
81
|
params: {
|
|
82
82
|
orderId: id,
|
package/src/modules/order.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {commonErrorCallback, calculateBasketIdParameter, restaurantIdEnv, updateBasket} from '../common';
|
|
1
|
+
import {commonErrorCallback, calculateBasketIdParameter, restaurantIdEnv, updateBasket, $http} from '../common';
|
|
3
2
|
|
|
4
3
|
const state = () => ({
|
|
5
4
|
productOrder: null,
|
|
@@ -73,7 +72,7 @@ const actions = {
|
|
|
73
72
|
// let delivery_time =
|
|
74
73
|
// `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()
|
|
75
74
|
// } ${(date.getHours()).toString().padStart(2, '0')}:${(date.getMinutes()).toString().padStart(2, '0')}`
|
|
76
|
-
return
|
|
75
|
+
return $http
|
|
77
76
|
.post("api/basket/create", {
|
|
78
77
|
...delivery_time,
|
|
79
78
|
restaurantId: data.restaurantId,
|
|
@@ -94,7 +93,7 @@ const actions = {
|
|
|
94
93
|
},
|
|
95
94
|
createBasketFromOrder({ dispatch }, data) {
|
|
96
95
|
const basketData = JSON.parse(localStorage.getItem("basket") || "[]");
|
|
97
|
-
return
|
|
96
|
+
return $http
|
|
98
97
|
.post("api/order/create-basket", data)
|
|
99
98
|
.then(async res => {
|
|
100
99
|
basketData.push({
|
|
@@ -128,7 +127,7 @@ const actions = {
|
|
|
128
127
|
|
|
129
128
|
|
|
130
129
|
|
|
131
|
-
return
|
|
130
|
+
return $http.post('api/basket/set-table', {
|
|
132
131
|
restaurantId: data.restaurantId,
|
|
133
132
|
...basketId,
|
|
134
133
|
...table,
|
|
@@ -157,7 +156,7 @@ const actions = {
|
|
|
157
156
|
|
|
158
157
|
data.quantity = parseInt(data.quantity);
|
|
159
158
|
|
|
160
|
-
|
|
159
|
+
$http.post("api/basket/add", {
|
|
161
160
|
...basketId,
|
|
162
161
|
productId: data.productId,
|
|
163
162
|
quantity: !data.quantity || data.quantity < 1 ? 1 : data.quantity,
|
|
@@ -190,7 +189,7 @@ const actions = {
|
|
|
190
189
|
} : {}
|
|
191
190
|
|
|
192
191
|
basketProduct.changingQuantity = true;
|
|
193
|
-
|
|
192
|
+
$http.get("api/basket/remove", {
|
|
194
193
|
params: {
|
|
195
194
|
...basketId,
|
|
196
195
|
basketProductId: basketProduct.basketProductId,
|
|
@@ -223,7 +222,7 @@ const actions = {
|
|
|
223
222
|
} : {}
|
|
224
223
|
|
|
225
224
|
basketProduct.changingQuantity = true;
|
|
226
|
-
|
|
225
|
+
$http.get("api/basket/remove", {
|
|
227
226
|
params: {
|
|
228
227
|
...basketId,
|
|
229
228
|
basketProductId: data.basketProductId,
|
|
@@ -255,7 +254,7 @@ const actions = {
|
|
|
255
254
|
} : {}
|
|
256
255
|
|
|
257
256
|
basketProduct.deleting = true;
|
|
258
|
-
return
|
|
257
|
+
return $http.get("api/basket/delete-basket-product", {
|
|
259
258
|
params: {
|
|
260
259
|
...basketId,
|
|
261
260
|
basketProductId: basketProduct.basketProductId,
|
|
@@ -288,7 +287,7 @@ const actions = {
|
|
|
288
287
|
} : {}
|
|
289
288
|
|
|
290
289
|
basketProduct.deleting = true;
|
|
291
|
-
|
|
290
|
+
$http.get("api/basket/delete-basket-product", {
|
|
292
291
|
params: {
|
|
293
292
|
...basketId,
|
|
294
293
|
basketProductId: data.basketProductId,
|
|
@@ -315,7 +314,7 @@ const actions = {
|
|
|
315
314
|
data.quantity = parseInt(data.quantity);
|
|
316
315
|
|
|
317
316
|
if(basketProduct) basketProduct.changingQuantity = true;
|
|
318
|
-
return
|
|
317
|
+
return $http.post('api/basket/add-product-package-items', {
|
|
319
318
|
...basketId,
|
|
320
319
|
...data,
|
|
321
320
|
quantity: !data.quantity || data.quantity < 1 ? 1 : data.quantity,
|
|
@@ -332,7 +331,7 @@ const actions = {
|
|
|
332
331
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
333
332
|
basketId: basket.find((basket) => basket.restaurantId == data.restaurantId).basketId
|
|
334
333
|
} : {}
|
|
335
|
-
return
|
|
334
|
+
return $http
|
|
336
335
|
.post("api/basket/add-address", {
|
|
337
336
|
...basketId,
|
|
338
337
|
restaurantId: data.restaurantId,
|
|
@@ -350,7 +349,7 @@ const actions = {
|
|
|
350
349
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
351
350
|
basketId: basket.find((basket) => basket.restaurantId == data.restaurantId).basketId
|
|
352
351
|
} : {}
|
|
353
|
-
return
|
|
352
|
+
return $http
|
|
354
353
|
.get("api/order/check-address", {
|
|
355
354
|
params: {
|
|
356
355
|
...basketId,
|
|
@@ -382,7 +381,7 @@ const actions = {
|
|
|
382
381
|
basketId: data.basketId
|
|
383
382
|
} : {}
|
|
384
383
|
const restaurantID = data.restaurantId ? { restaurantId: data.restaurantId } : {}
|
|
385
|
-
return
|
|
384
|
+
return $http
|
|
386
385
|
.post("api/order/create-order", {
|
|
387
386
|
...basketId,
|
|
388
387
|
...restaurantID,
|
|
@@ -435,7 +434,7 @@ const actions = {
|
|
|
435
434
|
);
|
|
436
435
|
},
|
|
437
436
|
getOrder({ commit }, orderId) {
|
|
438
|
-
return
|
|
437
|
+
return $http
|
|
439
438
|
.get("api/order", {
|
|
440
439
|
params: {
|
|
441
440
|
orderId: orderId
|
|
@@ -462,7 +461,7 @@ const actions = {
|
|
|
462
461
|
);
|
|
463
462
|
},
|
|
464
463
|
requestBill({ }, orderId) {
|
|
465
|
-
return
|
|
464
|
+
return $http
|
|
466
465
|
.get("api/order/bill-request", {
|
|
467
466
|
params: {
|
|
468
467
|
order_id: orderId
|
|
@@ -486,7 +485,7 @@ const actions = {
|
|
|
486
485
|
} : {}
|
|
487
486
|
const restaurantID = data.restaurantId ? { restaurantId: data.restaurantId } : {}
|
|
488
487
|
|
|
489
|
-
|
|
488
|
+
$http.get('api/payment/prepare', {
|
|
490
489
|
params: {
|
|
491
490
|
...basketId,
|
|
492
491
|
...restaurantID,
|
|
@@ -498,7 +497,7 @@ const actions = {
|
|
|
498
497
|
);
|
|
499
498
|
},
|
|
500
499
|
updatePaymentStatus({ dispatch, commit }, data) {
|
|
501
|
-
return
|
|
500
|
+
return $http
|
|
502
501
|
.get(`api/payment/update`, { params: { paymentId: data.paymentId } })
|
|
503
502
|
.then((res) => {
|
|
504
503
|
const status = res.data.data.status;
|
|
@@ -530,7 +529,7 @@ const actions = {
|
|
|
530
529
|
if (!data.postalCode || !data.deliveryType) {
|
|
531
530
|
return
|
|
532
531
|
}
|
|
533
|
-
return
|
|
532
|
+
return $http
|
|
534
533
|
.get(`api/restaurant/shipping-price`, {
|
|
535
534
|
params: {
|
|
536
535
|
deliveryType: data.deliveryType,
|
|
@@ -569,7 +568,7 @@ const actions = {
|
|
|
569
568
|
if (!data.postalCode || !data.deliveryType) {
|
|
570
569
|
return
|
|
571
570
|
}
|
|
572
|
-
return
|
|
571
|
+
return $http
|
|
573
572
|
.get(`api/basket/total-price`, {
|
|
574
573
|
params: {
|
|
575
574
|
...basketId,
|
|
@@ -597,7 +596,7 @@ const actions = {
|
|
|
597
596
|
parseInt(basket.restaurantId) === parseInt(restaurantId)
|
|
598
597
|
).basketId
|
|
599
598
|
} : {}
|
|
600
|
-
return
|
|
599
|
+
return $http
|
|
601
600
|
.post("api/basket/add-delivery-time", {
|
|
602
601
|
...basketId,
|
|
603
602
|
delivery_time: data.date && data.time ? data.date + " " + data.time : null,
|
|
@@ -618,7 +617,7 @@ const actions = {
|
|
|
618
617
|
);
|
|
619
618
|
},
|
|
620
619
|
getOrderHistory({ commit }, data) {
|
|
621
|
-
return
|
|
620
|
+
return $http
|
|
622
621
|
.get("api/order/history", { params: data })
|
|
623
622
|
.then((res) => {
|
|
624
623
|
commit('setorderList', res.data.data)
|
|
@@ -632,7 +631,7 @@ const actions = {
|
|
|
632
631
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
633
632
|
basketId: basket.find((basket) => basket.restaurantId == data.restaurantId).basketId
|
|
634
633
|
} : {}
|
|
635
|
-
return
|
|
634
|
+
return $http.post('api/basket/add-voucher-to-basket', null, {
|
|
636
635
|
params: {
|
|
637
636
|
voucherCode: data.voucherCode,
|
|
638
637
|
restaurantId: data.restaurantId,
|
|
@@ -653,7 +652,7 @@ const actions = {
|
|
|
653
652
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
654
653
|
basketId: basket.find((basket) => basket.restaurantId == restaurantId).basketId
|
|
655
654
|
} : {}
|
|
656
|
-
return
|
|
655
|
+
return $http.get('api/basket/remove-voucher-from-basket', {
|
|
657
656
|
params: {
|
|
658
657
|
...basketId,
|
|
659
658
|
restaurantId: restaurantId
|
|
@@ -673,7 +672,7 @@ const actions = {
|
|
|
673
672
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
674
673
|
basketId: basket.find((basket) => basket.restaurantId == data.restaurantId).basketId
|
|
675
674
|
} : {}
|
|
676
|
-
return
|
|
675
|
+
return $http.post('api/basket/add-tip', {
|
|
677
676
|
...basketId,
|
|
678
677
|
restaurantId: data.restaurantId,
|
|
679
678
|
tip_price: data.tip_price
|
|
@@ -692,7 +691,7 @@ const actions = {
|
|
|
692
691
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
693
692
|
basketId: basket.find((basket) => basket.restaurantId == restaurantId).basketId
|
|
694
693
|
} : {}
|
|
695
|
-
return
|
|
694
|
+
return $http.put('api/basket/remove-tip-from-basket', {
|
|
696
695
|
...basketId,
|
|
697
696
|
restaurantId: restaurantId,
|
|
698
697
|
}).then((result) => {
|
|
@@ -710,7 +709,7 @@ const actions = {
|
|
|
710
709
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
|
711
710
|
basketId: basket.find((basket) => basket.restaurantId == data.restaurantId).basketId
|
|
712
711
|
} : {}
|
|
713
|
-
return
|
|
712
|
+
return $http.post('api/order/is-valid', null, {
|
|
714
713
|
params: {
|
|
715
714
|
restaurantId: data.restaurantId,
|
|
716
715
|
...basketId
|
|
@@ -733,7 +732,7 @@ const actions = {
|
|
|
733
732
|
return {type: 'error', msg: 'Basket not found'};
|
|
734
733
|
}
|
|
735
734
|
|
|
736
|
-
return
|
|
735
|
+
return $http.post('api/basket/update-extraInfo', {
|
|
737
736
|
basketId,
|
|
738
737
|
restaurantId: data.restaurantId || restaurantIdEnv,
|
|
739
738
|
...data
|
package/src/modules/product.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {commonErrorCallback, calculateBasketIdParameter, updateBasket, restaurantIdEnv} from '../common';
|
|
1
|
+
import {commonErrorCallback, calculateBasketIdParameter, updateBasket, restaurantIdEnv, $http} from '../common';
|
|
3
2
|
|
|
4
3
|
const state = () => ({
|
|
5
4
|
selectedTime: null,
|
|
@@ -141,11 +140,11 @@ const mutations = {
|
|
|
141
140
|
}
|
|
142
141
|
};
|
|
143
142
|
const actions = {
|
|
144
|
-
// TODO: note the
|
|
143
|
+
// TODO: note the $http in loop
|
|
145
144
|
// Orderiom api doesn't use this function
|
|
146
145
|
// check whether ordermood is using this function or not
|
|
147
146
|
getCategoriesWithProducts({ commit, dispatch }, restaurantId) {
|
|
148
|
-
return
|
|
147
|
+
return $http.get("api/restaurant/category", {
|
|
149
148
|
params: {
|
|
150
149
|
restaurantId: restaurantId
|
|
151
150
|
}
|
|
@@ -153,7 +152,7 @@ const actions = {
|
|
|
153
152
|
let categories = res.data.data
|
|
154
153
|
commit("setSelectedCategory", categories[0]);
|
|
155
154
|
|
|
156
|
-
|
|
155
|
+
$http.get("api/restaurant/category", {
|
|
157
156
|
params: {
|
|
158
157
|
restaurantId: restaurantId,
|
|
159
158
|
extra: 1
|
|
@@ -189,13 +188,13 @@ const actions = {
|
|
|
189
188
|
);
|
|
190
189
|
},
|
|
191
190
|
getCategories({ commit, dispatch }, restaurantId) {
|
|
192
|
-
return
|
|
191
|
+
return $http
|
|
193
192
|
.get("api/restaurant/category", { params: { restaurantId: restaurantId } })
|
|
194
193
|
.then((res) => {
|
|
195
194
|
let categories = res.data.data;
|
|
196
195
|
//TODO: why calling an api write after another while we can do it together?
|
|
197
196
|
//TODO: this api call returns empty on restaurant refresh
|
|
198
|
-
|
|
197
|
+
$http
|
|
199
198
|
.get("api/restaurant/category", { params: { restaurantId: restaurantId, extra: 1 } })
|
|
200
199
|
.then((res) => {
|
|
201
200
|
if (res.data.data.length) {
|
|
@@ -243,7 +242,7 @@ const actions = {
|
|
|
243
242
|
return { type: 'error', msg: 'Basket not found' }
|
|
244
243
|
}
|
|
245
244
|
|
|
246
|
-
return
|
|
245
|
+
return $http.get("api/restaurant/products", {params: {
|
|
247
246
|
categoryId: data.category.id,
|
|
248
247
|
restaurantId: data.restaurantId,
|
|
249
248
|
delivery_time: data.delivery_time || undefined,
|
|
@@ -272,7 +271,7 @@ const actions = {
|
|
|
272
271
|
}
|
|
273
272
|
|
|
274
273
|
commit('startFetchingBasket');
|
|
275
|
-
return
|
|
274
|
+
return $http.get('api/basket', {
|
|
276
275
|
params: {
|
|
277
276
|
basketId,
|
|
278
277
|
restaurantId: data.restaurantId || restaurantIdEnv
|
|
@@ -287,7 +286,7 @@ const actions = {
|
|
|
287
286
|
});
|
|
288
287
|
},
|
|
289
288
|
getAttributeItems({ commit }, data) {
|
|
290
|
-
return
|
|
289
|
+
return $http.get('api/restaurant/category-attributes-items', {
|
|
291
290
|
params: {
|
|
292
291
|
restaurantId: data.restaurantId, categoryId: data.category.id,
|
|
293
292
|
}
|
|
@@ -298,7 +297,7 @@ const actions = {
|
|
|
298
297
|
);
|
|
299
298
|
},
|
|
300
299
|
getPackage({ commit }, data) {
|
|
301
|
-
return
|
|
300
|
+
return $http.get('api/restaurant/product-packages', {
|
|
302
301
|
params: {
|
|
303
302
|
productId: data.productId,
|
|
304
303
|
restaurantId: data.restaurantId
|
|
@@ -310,7 +309,7 @@ const actions = {
|
|
|
310
309
|
);
|
|
311
310
|
},
|
|
312
311
|
searchOnProducts({ commit }, data) {
|
|
313
|
-
return
|
|
312
|
+
return $http.get('api/restaurant/product/search', {
|
|
314
313
|
params: {
|
|
315
314
|
query: data.query,
|
|
316
315
|
restaurantId: data.restaurantId
|
|
@@ -333,7 +332,7 @@ const actions = {
|
|
|
333
332
|
const shoppingCartItems = rootState.orderiomApiPackage.product.ShoppingCart.length;
|
|
334
333
|
|
|
335
334
|
commit('startChangingDeliveryType');
|
|
336
|
-
return
|
|
335
|
+
return $http.post('api/basket/change-delivery-method', {
|
|
337
336
|
deliveryType,
|
|
338
337
|
basketId,
|
|
339
338
|
restaurantId: basketId ? undefined : (restaurantId || restaurantIdEnv)
|
|
@@ -376,7 +375,7 @@ const actions = {
|
|
|
376
375
|
|
|
377
376
|
// TODO: It is recommended to use a new api instead of multiple api calls inside a loop.
|
|
378
377
|
return Promise.all(list.map(category =>
|
|
379
|
-
|
|
378
|
+
$http.get("api/restaurant/products", {
|
|
380
379
|
params: {
|
|
381
380
|
categoryId: category.id,
|
|
382
381
|
restaurantId: restaurantId || restaurantIdEnv,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { commonErrorCallback, restaurantIdEnv } from '../common';
|
|
1
|
+
import { commonErrorCallback, restaurantIdEnv, $http } from '../common';
|
|
3
2
|
|
|
4
3
|
const state = () => ({
|
|
5
4
|
restaurantInfo: {},
|
|
@@ -59,7 +58,7 @@ const mutations = {
|
|
|
59
58
|
|
|
60
59
|
const actions = {
|
|
61
60
|
getRestaurants({ commit }, data) {
|
|
62
|
-
return
|
|
61
|
+
return $http.get('api/restaurant', {
|
|
63
62
|
params: {
|
|
64
63
|
postalCode: data.postalCode,
|
|
65
64
|
deliveryType: data.deliveryType,
|
|
@@ -79,7 +78,7 @@ const actions = {
|
|
|
79
78
|
},
|
|
80
79
|
getRestaurantInfo({ commit }, restaurantId) {
|
|
81
80
|
commit('startFetchingRestaurantInfo');
|
|
82
|
-
return
|
|
81
|
+
return $http.get('api/restaurant/restaurant-by-id', { params: { restaurantId } }).then(result => {
|
|
83
82
|
commit('setRestaurantInfo', result.data.data[0]);
|
|
84
83
|
}).catch(
|
|
85
84
|
commonErrorCallback()
|
|
@@ -88,7 +87,7 @@ const actions = {
|
|
|
88
87
|
});
|
|
89
88
|
},
|
|
90
89
|
getRestaurantIdBySlug({ commit }, restaurantSlug) {
|
|
91
|
-
return
|
|
90
|
+
return $http.get('api/restaurant/id', {
|
|
92
91
|
params: {
|
|
93
92
|
slug: restaurantSlug,
|
|
94
93
|
}
|
|
@@ -99,7 +98,7 @@ const actions = {
|
|
|
99
98
|
);
|
|
100
99
|
},
|
|
101
100
|
contact({ }, data) {
|
|
102
|
-
return
|
|
101
|
+
return $http.post('api/contact', data).then((result) => {
|
|
103
102
|
return {
|
|
104
103
|
type: 'success',
|
|
105
104
|
msg: 'your message has been delivered successfully!'
|
|
@@ -109,14 +108,14 @@ const actions = {
|
|
|
109
108
|
);
|
|
110
109
|
},
|
|
111
110
|
getImprint({ commit }, restaurantId) {
|
|
112
|
-
return
|
|
111
|
+
return $http.get('api/restaurant/imprint', { params: { restaurantId: restaurantId } }).then(res => {
|
|
113
112
|
commit('setImprint', res.data.data.imprint)
|
|
114
113
|
}).catch(
|
|
115
114
|
commonErrorCallback()
|
|
116
115
|
)
|
|
117
116
|
},
|
|
118
117
|
Newsletter({ }, data) {
|
|
119
|
-
return
|
|
118
|
+
return $http.post('api/newsletter/create', null, {
|
|
120
119
|
params: data
|
|
121
120
|
}).then((res) => {
|
|
122
121
|
return {
|
|
@@ -128,7 +127,7 @@ const actions = {
|
|
|
128
127
|
)
|
|
129
128
|
},
|
|
130
129
|
getTables({ commit }, restaurantId) {
|
|
131
|
-
return
|
|
130
|
+
return $http.get('api/restaurant/tables', {
|
|
132
131
|
params: {
|
|
133
132
|
restaurantId: restaurantId
|
|
134
133
|
}
|
|
@@ -143,7 +142,7 @@ const actions = {
|
|
|
143
142
|
);
|
|
144
143
|
},
|
|
145
144
|
addReservedTables({ commit }, data) {
|
|
146
|
-
return
|
|
145
|
+
return $http
|
|
147
146
|
.post("api/restaurant/reserve-table", {
|
|
148
147
|
restaurantId: data.restaurantId || restaurantIdEnv,
|
|
149
148
|
people: data.people,
|
|
@@ -163,7 +162,7 @@ const actions = {
|
|
|
163
162
|
);
|
|
164
163
|
},
|
|
165
164
|
getBlogs({ commit }, restaurantId) {
|
|
166
|
-
return
|
|
165
|
+
return $http.get('api/blogs', {
|
|
167
166
|
params: restaurantId
|
|
168
167
|
}).then(res => {
|
|
169
168
|
commit('setBlogs', res.data.data)
|
|
@@ -178,7 +177,7 @@ const actions = {
|
|
|
178
177
|
},
|
|
179
178
|
getBlogsByTag({ commit },{tagId, restaurantId = null}) {
|
|
180
179
|
commit('startFetchingBlogs');
|
|
181
|
-
return
|
|
180
|
+
return $http.get('/api/blogs/by-tag', {
|
|
182
181
|
params: {
|
|
183
182
|
restaurantId: restaurantId || restaurantIdEnv,
|
|
184
183
|
tagId
|
|
@@ -198,7 +197,7 @@ const actions = {
|
|
|
198
197
|
})
|
|
199
198
|
},
|
|
200
199
|
getBlog({ commit }, blogId) {
|
|
201
|
-
return
|
|
200
|
+
return $http.get('api/blogs/show', {
|
|
202
201
|
params: blogId
|
|
203
202
|
}).then(res => {
|
|
204
203
|
commit('setBlog', res.data.data)
|
|
@@ -212,7 +211,7 @@ const actions = {
|
|
|
212
211
|
})
|
|
213
212
|
},
|
|
214
213
|
getBlogBySlug({ commit },{blogSlug, restaurantId = null}) {
|
|
215
|
-
return
|
|
214
|
+
return $http.get('api/blogs/show/slug', { params: {blogSlug, restaurantId: restaurantId || restaurantIdEnv}}).then(res => {
|
|
216
215
|
commit('setBlog', res.data.data);
|
|
217
216
|
return { type: 'success', msg: 'ok' }
|
|
218
217
|
}).catch(error => {
|
|
@@ -221,7 +220,7 @@ const actions = {
|
|
|
221
220
|
})
|
|
222
221
|
},
|
|
223
222
|
getTestimonials({ commit }, data) {
|
|
224
|
-
return
|
|
223
|
+
return $http.get('api/testimonials', {
|
|
225
224
|
params: data
|
|
226
225
|
}).then(res => {
|
|
227
226
|
commit('setTestimonials', res.data.data)
|