orderiom-api-package
Advanced tools
Comparing version 0.2.58 to 0.3.0
{ | ||
"name": "orderiom-api-package", | ||
"version": "0.2.58", | ||
"version": "0.3.0", | ||
"description": "This package will install all necessary API calls for every orderiom restaurant", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -161,3 +161,7 @@ { | ||
"pattern_is_required": "Sie müssen Ihrem Muster Produkte hinzufügen.", | ||
"newsletter_successfully_added": "Ihre E-Mail wurde erfolgreich hinzugefügt." | ||
"newsletter_successfully_added": "Ihre E-Mail wurde erfolgreich hinzugefügt.", | ||
"There was an error in fetching the blogs": "Beim Abrufen der Blogs ist ein Fehler aufgetreten", | ||
"There was an error in fetching the blog": "Beim Abrufen des Blogs ist ein Fehler aufgetreten", | ||
"Something went wrong": "Etwas ist schief gelaufen", | ||
"Basket not found": "Korb nicht gefunden" | ||
} |
@@ -161,3 +161,7 @@ { | ||
"pattern_is_required": "you have to add products to your pattern.", | ||
"newsletter_successfully_added": "Your email has been added successfuly." | ||
"newsletter_successfully_added": "Your email has been added successfuly.", | ||
"There was an error in fetching the blogs": "There was an error in fetching the blogs", | ||
"There was an error in fetching the blog": "There was an error in fetching the blog", | ||
"Something went wrong": "Something went wrong", | ||
"Basket not found": "Basket not found" | ||
} |
@@ -706,3 +706,3 @@ import axios from "axios"; | ||
axios.post('api/basket/update-extraInfo', { | ||
return axios.post('api/basket/update-extraInfo', { | ||
basketId, | ||
@@ -712,5 +712,6 @@ ...data | ||
updateBasket({commit, basketId, res, isOutsideProduct: true}) | ||
).catch( | ||
commonErrorCallback() | ||
); | ||
).catch(err => { | ||
console.error(err); | ||
return false; | ||
}); | ||
} | ||
@@ -717,0 +718,0 @@ } |
@@ -360,3 +360,53 @@ import axios from "axios"; | ||
}); | ||
} | ||
}, | ||
getProductsFromAllCategories({ commit, state, rootState }, categories = null) { | ||
let basketId = undefined; | ||
try{ | ||
basketId = calculateBasketIdParameter(!!rootState.orderiomApiPackage.auth.privateToken); | ||
} catch(e) { | ||
console.error(e); | ||
return { type: 'error', msg: 'Basket not found' } | ||
} | ||
const result = []; | ||
// TODO: It is recommended to use a new api instead of multiple api calls inside a loop. | ||
(categories || state.categories).forEach(category => { | ||
axios.get("api/restaurant/products", { | ||
params: { | ||
categoryId: data.category.id, | ||
restaurantId, | ||
basketId | ||
} | ||
}).then(res => { | ||
const products = res.data.data; | ||
products.forEach(m => { | ||
const productFoundInShoppingCart = state.ShoppingCart.find(p => p.RestaurantProductId === m.id); | ||
if (!productFoundInShoppingCart) { | ||
m.quantity = 0; | ||
return; | ||
} | ||
if (!m.is_package) { | ||
m.quantity = productFoundInShoppingCart.quantity; | ||
return; | ||
} | ||
let qty = 0; | ||
state.ShoppingCart.forEach(b => { | ||
if (b.RestaurantProductId !== m.id) return; | ||
qty += b.quantity; | ||
}); | ||
m.quantity = qty; | ||
}) | ||
result.push({...category, products}); | ||
}).catch( | ||
commonErrorCallback() | ||
); | ||
}); | ||
return result | ||
}, | ||
}; | ||
@@ -363,0 +413,0 @@ |
93749
2244