diff --git a/front/components/Calculator/CalculatorForm.vue b/front/components/Calculator/CalculatorForm.vue index 27c38a4..8dcc4af 100644 --- a/front/components/Calculator/CalculatorForm.vue +++ b/front/components/Calculator/CalculatorForm.vue @@ -31,7 +31,22 @@ - + + Wartości odżywcze: + + + + + + @@ -47,6 +62,12 @@ ingredients_idx: 1, ingredients: { items: [] + }, + nutrition: { + kcal: 0, + carbohydrates: 0, + protein: 0, + fat: 0 } }; }, @@ -59,6 +80,10 @@ items: [] }; this.suggestions = [] + this.nutrition.kcal = 0; + this.nutrition.carbohydrates = 0; + this.nutrition.protein = 0; + this.nutrition.fat = 0; }, handleAddIngredient() { this.ingredients_idx++; @@ -83,6 +108,20 @@ .then((res) => { this.suggestions = res.data.data.products.data }) + }, + calculate() { + const ingredients_list = this.ingredients.items.map(ing => ({ + id: ing.id, + weight: ing.weight || 1 + })); + this.$axios.post('/calculate', {products: ingredients_list}) + .then((response) => { + this.nutrition = response.data.data.nutrition; + }) + .catch((error) => { + console.log(error); + this.$Message.error('Błąd!'); + }); } } }; diff --git a/front/pages/index.vue b/front/pages/index.vue index 1cb004b..f0c2c08 100644 --- a/front/pages/index.vue +++ b/front/pages/index.vue @@ -23,9 +23,9 @@ - +
-

Dieta

+

Historia

@@ -39,6 +39,7 @@ +