orderiom-api-package 0.3.0 → 0.3.2
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 +33 -34
- package/src/modules/restaurant.js +1 -1
package/package.json
CHANGED
package/src/modules/product.js
CHANGED
|
@@ -364,49 +364,48 @@ const actions = {
|
|
|
364
364
|
basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken);
|
|
365
365
|
} catch(e) {
|
|
366
366
|
console.error(e);
|
|
367
|
-
return { type: 'error', msg: 'Basket not found' }
|
|
367
|
+
return { type: 'error', msg: 'Basket not found', data: [] }
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
const
|
|
370
|
+
const list = (categories || state.categories);
|
|
371
371
|
|
|
372
372
|
// TODO: It is recommended to use a new api instead of multiple api calls inside a loop.
|
|
373
|
-
|
|
373
|
+
return Promise.all(list.map(category =>
|
|
374
374
|
axios.get("api/restaurant/products", {
|
|
375
375
|
params: {
|
|
376
|
-
categoryId:
|
|
376
|
+
categoryId: category.id,
|
|
377
377
|
restaurantId,
|
|
378
378
|
basketId
|
|
379
379
|
}
|
|
380
|
-
})
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
return result
|
|
380
|
+
})
|
|
381
|
+
)).then(resArray => ({
|
|
382
|
+
type: 'success',
|
|
383
|
+
msg: '',
|
|
384
|
+
data: resArray.map((res, resIndex) => ({
|
|
385
|
+
...list[resIndex],
|
|
386
|
+
products: res.data.data
|
|
387
|
+
}))
|
|
388
|
+
})).catch(error => {
|
|
389
|
+
const status = error.response ? error.response.status : null;
|
|
390
|
+
if (status === 422) {
|
|
391
|
+
return {
|
|
392
|
+
type: 'error',
|
|
393
|
+
msg: Object.values(error.response.data.error.validation).map(m => m[0]).toString(),
|
|
394
|
+
data: []
|
|
395
|
+
}
|
|
396
|
+
} else if ([401, 403, 404, 400].includes(status)) {
|
|
397
|
+
return {
|
|
398
|
+
type: 'error',
|
|
399
|
+
msg: error.response.data.message.body,
|
|
400
|
+
data: []
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return {
|
|
404
|
+
type: 'error',
|
|
405
|
+
msg: 'Something went wrong',
|
|
406
|
+
data: []
|
|
407
|
+
}
|
|
408
|
+
})
|
|
410
409
|
},
|
|
411
410
|
};
|
|
412
411
|
|
|
@@ -212,7 +212,7 @@ const actions = {
|
|
|
212
212
|
})
|
|
213
213
|
},
|
|
214
214
|
getBlogBySlug({ commit }, blogSlug) {
|
|
215
|
-
return axios.get('api/blogs/show/slug', { params: {blogSlug}}).then(res => {
|
|
215
|
+
return axios.get('api/blogs/show/slug', { params: {blogSlug, restaurantId}}).then(res => {
|
|
216
216
|
commit('setBlog', res.data.data);
|
|
217
217
|
return { type: 'success', msg: 'ok' }
|
|
218
218
|
}).catch(error => {
|