orderiom-api-package 0.3.35 → 0.3.37
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/common.js +2 -2
- package/src/modules/auth.js +3 -3
- package/src/modules/product.js +43 -42
package/package.json
CHANGED
package/src/common.js
CHANGED
|
@@ -2,7 +2,7 @@ import axios from "axios";
|
|
|
2
2
|
|
|
3
3
|
export const restaurantIdEnv = process.env.VUE_APP_RESTAURANT_ID
|
|
4
4
|
? parseInt(process.env.VUE_APP_RESTAURANT_ID)
|
|
5
|
-
: window.dynamicData.VUE_APP_RESTAURANT_ID
|
|
5
|
+
: window.dynamicData && window.dynamicData.VUE_APP_RESTAURANT_ID
|
|
6
6
|
? parseInt(window.dynamicData.VUE_APP_RESTAURANT_ID)
|
|
7
7
|
: null;
|
|
8
8
|
|
|
@@ -78,7 +78,7 @@ export function updateBasket({commit, basketId, res, restaurantId}){
|
|
|
78
78
|
return true;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
axios.defaults.baseURL =
|
|
81
|
+
axios.defaults.baseURL = process.env.VUE_APP_BASE_API_URL || window.dynamicData.VUE_APP_BASE_API_URL;
|
|
82
82
|
axios.interceptors.request.use(config => {
|
|
83
83
|
const token = localStorage.getItem("privateToken") || localStorage.getItem("publicToken");
|
|
84
84
|
if (token) config.headers["Authorization"] = `Bearer ${token}`;
|
package/src/modules/auth.js
CHANGED
|
@@ -55,9 +55,9 @@ const actions = {
|
|
|
55
55
|
auth({ commit }) {
|
|
56
56
|
return $http
|
|
57
57
|
.post("api/oauth/token", {
|
|
58
|
-
grant_type:
|
|
59
|
-
client_id:
|
|
60
|
-
client_secret:
|
|
58
|
+
grant_type: process.env.VUE_APP_GRANT_TYPE || window.dynamicData.VUE_APP_GRANT_TYPE,
|
|
59
|
+
client_id: process.env.VUE_APP_CLIENT_ID || window.dynamicData.VUE_APP_CLIENT_ID,
|
|
60
|
+
client_secret: process.env.VUE_APP_CLIENT_SECRET || window.dynamicData.VUE_APP_CLIENT_SECRET
|
|
61
61
|
})
|
|
62
62
|
.then(res => {
|
|
63
63
|
commit('setPublicToken', res.data.data.access_token)
|
package/src/modules/product.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {commonErrorCallback, calculateBasketIdParameter, updateBasket, restaurantIdEnv, $http} from '../common';
|
|
2
|
+
import Vue from 'vue';
|
|
2
3
|
|
|
3
4
|
const state = () => ({
|
|
4
5
|
selectedTime: null,
|
|
@@ -147,49 +148,49 @@ const actions = {
|
|
|
147
148
|
// Orderiom api doesn't use this function
|
|
148
149
|
// check whether ordermood is using this function or not
|
|
149
150
|
getCategoriesWithProducts({ commit, dispatch }, restaurantId) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
return $http
|
|
152
|
+
.get("api/restaurant/category", { params: { restaurantId: restaurantId } })
|
|
153
|
+
.then((res) => {
|
|
154
|
+
let categories = res.data.data
|
|
155
|
+
commit("setSelectedCategory", categories[0]);
|
|
156
|
+
$http
|
|
157
|
+
.get("api/restaurant/category", { params: { restaurantId: restaurantId, extra: 1 } })
|
|
158
|
+
.then((res) => {
|
|
159
|
+
if (res.data.data.length) {
|
|
160
|
+
categories = [...categories, ...res.data.data];
|
|
161
|
+
for (let i = 0; i < categories.length; i++) {
|
|
162
|
+
const element = categories[i];
|
|
163
|
+
dispatch("getProducts", {
|
|
164
|
+
category: element,
|
|
165
|
+
restaurantId: restaurantId,
|
|
166
|
+
})
|
|
167
|
+
.then((res) => {
|
|
168
|
+
Vue.set(element, 'products', res.data);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
commit('setCategories', categories);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
commit('setCategories', categories);
|
|
175
|
+
for (let i = 0; i < categories.length; i++) {
|
|
176
|
+
const element = categories[i];
|
|
177
|
+
dispatch("getProducts", {
|
|
178
|
+
category: element,
|
|
179
|
+
restaurantId: restaurantId,
|
|
180
|
+
})
|
|
181
|
+
.then((res) => {
|
|
182
|
+
Vue.set(element, 'products', res.data)
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
})
|
|
188
|
+
})
|
|
189
|
+
.catch(
|
|
190
|
+
commonErrorCallback()
|
|
191
|
+
);
|
|
192
|
+
},
|
|
157
193
|
|
|
158
|
-
$http.get("api/restaurant/category", {
|
|
159
|
-
params: {
|
|
160
|
-
restaurantId: restaurantId,
|
|
161
|
-
extra: 1
|
|
162
|
-
}
|
|
163
|
-
}).then(res => {
|
|
164
|
-
if (res.data.data.length) {
|
|
165
|
-
categories = [...categories, ...res.data.data];
|
|
166
|
-
categories.forEach(cat => {
|
|
167
|
-
dispatch("getProducts", {
|
|
168
|
-
category: cat,
|
|
169
|
-
restaurantId: restaurantId,
|
|
170
|
-
}).then(res => {
|
|
171
|
-
cat.products = res.data;
|
|
172
|
-
cat.products.push();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
commit('setCategories', categories);
|
|
176
|
-
} else {
|
|
177
|
-
commit('setCategories', categories);
|
|
178
|
-
categories.forEach(cat => {
|
|
179
|
-
dispatch("getProducts", {
|
|
180
|
-
category: cat,
|
|
181
|
-
restaurantId: restaurantId,
|
|
182
|
-
}).then(res => {
|
|
183
|
-
cat.products = res.data;
|
|
184
|
-
cat.products.push();
|
|
185
|
-
});
|
|
186
|
-
})
|
|
187
|
-
}
|
|
188
|
-
})
|
|
189
|
-
}).catch(
|
|
190
|
-
commonErrorCallback()
|
|
191
|
-
);
|
|
192
|
-
},
|
|
193
194
|
getCategories({ commit, dispatch }, restaurantId) {
|
|
194
195
|
return $http
|
|
195
196
|
.get("api/restaurant/category", { params: { restaurantId: restaurantId } })
|