orderiom-api-package 0.3.28 → 0.3.29
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/modules/product.js +39 -39
package/package.json
CHANGED
package/src/modules/product.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
-
import Vue from 'vue';
|
|
3
2
|
import {commonErrorCallback, calculateBasketIdParameter, updateBasket, restaurantIdEnv} from '../common';
|
|
4
3
|
|
|
5
4
|
const state = () => ({
|
|
@@ -146,47 +145,48 @@ const actions = {
|
|
|
146
145
|
// Orderiom api doesn't use this function
|
|
147
146
|
// check whether ordermood is using this function or not
|
|
148
147
|
getCategoriesWithProducts({ commit, dispatch }, restaurantId) {
|
|
149
|
-
return axios
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
.then((res) => {
|
|
157
|
-
if (res.data.data.length) {
|
|
158
|
-
categories = [...categories, ...res.data.data];
|
|
159
|
-
for (let i = 0; i < categories.length; i++) {
|
|
160
|
-
const element = categories[i];
|
|
161
|
-
dispatch("getProducts", {
|
|
162
|
-
category: element,
|
|
163
|
-
restaurantId: restaurantId,
|
|
164
|
-
})
|
|
165
|
-
.then((res) => {
|
|
166
|
-
Vue.set(element, 'products', res.data);
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
commit('setCategories', categories);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
commit('setCategories', categories);
|
|
173
|
-
for (let i = 0; i < categories.length; i++) {
|
|
174
|
-
const element = categories[i];
|
|
175
|
-
dispatch("getProducts", {
|
|
176
|
-
category: element,
|
|
177
|
-
restaurantId: restaurantId,
|
|
178
|
-
})
|
|
179
|
-
.then((res) => {
|
|
180
|
-
Vue.set(element, 'products', res.data)
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
148
|
+
return axios.get("api/restaurant/category", {
|
|
149
|
+
params: {
|
|
150
|
+
restaurantId: restaurantId
|
|
151
|
+
}
|
|
152
|
+
}).then(res => {
|
|
153
|
+
let categories = res.data.data
|
|
154
|
+
commit("setSelectedCategory", categories[0]);
|
|
184
155
|
|
|
156
|
+
axios.get("api/restaurant/category", {
|
|
157
|
+
params: {
|
|
158
|
+
restaurantId: restaurantId,
|
|
159
|
+
extra: 1
|
|
160
|
+
}
|
|
161
|
+
}).then(res => {
|
|
162
|
+
if (res.data.data.length) {
|
|
163
|
+
categories = [...categories, ...res.data.data];
|
|
164
|
+
categories.forEach(cat => {
|
|
165
|
+
dispatch("getProducts", {
|
|
166
|
+
category: cat,
|
|
167
|
+
restaurantId: restaurantId,
|
|
168
|
+
}).then(res => {
|
|
169
|
+
cat.products = res.data;
|
|
170
|
+
cat.products.push();
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
commit('setCategories', categories);
|
|
174
|
+
} else {
|
|
175
|
+
commit('setCategories', categories);
|
|
176
|
+
categories.forEach(cat => {
|
|
177
|
+
dispatch("getProducts", {
|
|
178
|
+
category: cat,
|
|
179
|
+
restaurantId: restaurantId,
|
|
180
|
+
}).then(res => {
|
|
181
|
+
cat.products = res.data;
|
|
182
|
+
cat.products.push();
|
|
183
|
+
});
|
|
185
184
|
})
|
|
185
|
+
}
|
|
186
186
|
})
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
187
|
+
}).catch(
|
|
188
|
+
commonErrorCallback()
|
|
189
|
+
);
|
|
190
190
|
},
|
|
191
191
|
getCategories({ commit, dispatch }, restaurantId) {
|
|
192
192
|
return axios
|