orderiom-api-package 0.2.47 → 0.2.49
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/order.js +42 -0
- package/src/modules/product.js +1 -4
package/package.json
CHANGED
package/src/modules/order.js
CHANGED
|
@@ -113,6 +113,48 @@ const actions = {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
},
|
|
116
|
+
createBasketFromOrder({ dispatch }, data) {
|
|
117
|
+
const basketData = JSON.parse(localStorage.getItem("basket") || "[]");
|
|
118
|
+
return axios
|
|
119
|
+
.post("api/order/create-basket", data)
|
|
120
|
+
.then(async res => {
|
|
121
|
+
basketData.push({
|
|
122
|
+
restaurantId: restaurantId,
|
|
123
|
+
basketId: res.data.data.id,
|
|
124
|
+
});
|
|
125
|
+
localStorage.setItem("basket", JSON.stringify(basketData));
|
|
126
|
+
const result = await dispatch('product/getBasket', restaurantId, { root: true }) ;
|
|
127
|
+
return {
|
|
128
|
+
type: result ? 'success' : 'error',
|
|
129
|
+
msg: result ? 'Basket created' : 'There was an error in fetching the basket info',
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
.catch((error) => {
|
|
133
|
+
if(!error.response){
|
|
134
|
+
return {
|
|
135
|
+
type: 'error',
|
|
136
|
+
msg: 'There was an error in creating basket',
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const status = error.response.status;
|
|
140
|
+
if (status === 422) {
|
|
141
|
+
return {
|
|
142
|
+
type: 'error',
|
|
143
|
+
msg: Object.values(error.response.data.error.validation).map(m => { return m[0] }).toString()
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if ([401, 403, 404, 400].includes(status)) {
|
|
147
|
+
return {
|
|
148
|
+
type: 'error',
|
|
149
|
+
msg: error.response.data.message.body
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
type:'error',
|
|
154
|
+
msg:'There was an error in creating basket'
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
},
|
|
116
158
|
setTable({ rootState }, data) {
|
|
117
159
|
const basket = JSON.parse(localStorage.getItem("basket"));
|
|
118
160
|
const basketId = !rootState.orderiomApiPackage.auth.privateToken ? {
|
package/src/modules/product.js
CHANGED
|
@@ -478,10 +478,7 @@ const actions = {
|
|
|
478
478
|
return { type: 'error', msg: 'There was an error in updating the delivery type' }
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
-
dispatch('
|
|
482
|
-
restaurantId,
|
|
483
|
-
category: state.selectedCategory || state.categories[0]
|
|
484
|
-
});
|
|
481
|
+
dispatch('getCategories', restaurantId);
|
|
485
482
|
|
|
486
483
|
const result = await dispatch("getBasket", restaurantId);
|
|
487
484
|
|