orderiom-api-package 0.3.36 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orderiom-api-package",
3
- "version": "0.3.36",
3
+ "version": "0.3.37",
4
4
  "description": "This package will install all necessary API calls for every orderiom restaurant",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
- return $http.get("api/restaurant/category", {
151
- params: {
152
- restaurantId: restaurantId
153
- }
154
- }).then(res => {
155
- let categories = res.data.data
156
- commit("setSelectedCategory", categories[0]);
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 } })