Skip to content
Snippets Groups Projects
Commit f3c2a47e authored by Katarzyna Szlejter's avatar Katarzyna Szlejter
Browse files

Recipe view

parent 61b3e26d
No related branches found
No related tags found
1 merge request!23Recipe view
Pipeline #225586 passed
...@@ -352,18 +352,6 @@ export const API = { ...@@ -352,18 +352,6 @@ export const API = {
.catch(err => {console.log(err)}) .catch(err => {console.log(err)})
}, },
// addIngredientsToFridge: async (ingredientIds) => {
// const authStore = useAuthStore();
// return axios.delete(`${import.meta.env.VITE_BACKEND_URL}/shoppinglist/purchased`, {
// headers: { Authorization: `Bearer ${authStore.token}`},
// data: { ingredientIds }
// })
// .then((response) => {return response.data})
// .catch(err => {console.log(err)})
// },
addIngredientsToFridge: async (ingredients) => { addIngredientsToFridge: async (ingredients) => {
const authStore = useAuthStore(); const authStore = useAuthStore();
return axios.put(`${import.meta.env.VITE_BACKEND_URL}/shoppinglist/purchased`, ingredients, { return axios.put(`${import.meta.env.VITE_BACKEND_URL}/shoppinglist/purchased`, ingredients, {
...@@ -390,6 +378,25 @@ export const API = { ...@@ -390,6 +378,25 @@ export const API = {
}) })
}, },
/**
* Remove ingredients from fridge based on a recipe
* @param request
*/
removeIngredientsFromFridge: (request) => {
const authStore = useAuthStore();
axios.put(`${import.meta.env.VITE_BACKEND_URL}/fridge/ingredients`, request,
{
headers: { Authorization: "Bearer " + authStore.token }
})
.then((response) => {
console.log(response);
})
.catch((error) => {
throw new Error(error);
})
},
/** /**
* Deletes account from the * Deletes account from the
......
...@@ -13,6 +13,7 @@ export default { ...@@ -13,6 +13,7 @@ export default {
time: "", time: "",
ingredients: [], ingredients: [],
instructions: "", instructions: "",
recipeScalar: 1
} }
}, },
methods: { methods: {
...@@ -26,11 +27,8 @@ export default { ...@@ -26,11 +27,8 @@ export default {
this.instructions = recipe.instructions; this.instructions = recipe.instructions;
}) })
}, },
addIngredientsShoppingList() { adjustRecipeAmount(event) {
//TODO add ingredients to shopping list this.recipeScalar = event.target.value;
},
removeIngredientsFromFridge() {
//TODO remove used ingredients from fridge
} }
}, },
async mounted() { async mounted() {
...@@ -44,18 +42,19 @@ export default { ...@@ -44,18 +42,19 @@ export default {
<main> <main>
<h1>{{this.title}}</h1><br> <h1>{{this.title}}</h1><br>
<p>{{this.description}}</p><br> <p>{{this.description}}</p><br>
<div class="ingredients"> <div class="ingredient-container">
<h2>Ingredienser</h2> <div class="ingredients">
<ul> <h2>Ingredienser</h2>
<li v-for="ingredient in this.ingredients">{{ ingredient.item.name }} {{ ingredient.amount.quantity }} {{ingredient.amount.unit}}</li> <input class="recipe-scalar" type="number" min="1" max="20" placeholder="1" value="1" @change="event => adjustRecipeAmount(event)">
</ul> <ul>
<button @click="addIngredientsShoppingList">Legg til ingrediensene i handlekurven</button> <li v-for="ingredient in this.ingredients">{{ ingredient.item.name }} {{ ingredient.amount.quantity*this.recipeScalar }} {{ingredient.amount.unit}}</li>
</ul>
</div>
</div> </div>
<div class="instructions"> <div class="instructions">
<h2>Instruksjoner</h2> <h2>Instruksjoner</h2>
{{this.instructions}} {{this.instructions}}
</div> </div>
<button @click="removeIngredientsFromFridge">Fjern varene fra kjøleskapet</button>
</main> </main>
...@@ -70,16 +69,34 @@ export default { ...@@ -70,16 +69,34 @@ export default {
main { main {
padding: 20px 10px; padding: 20px 10px;
.ingredients { h1 {
margin-bottom: 20px; padding: 0;
} }
button { .ingredient-container {
min-height: 40px; .ingredients {
border-radius: 0; margin-bottom: 20px;
border: 1px solid; h2 {
cursor: pointer; display: inline-block;
padding: 5px; margin-right: 20px;
vertical-align: middle;
}
.recipe-scalar {
display: inline-block;
height: 40px;
width: 60px;
font-size: 16px;
padding: 5px;
vertical-align: middle;
}
ul {
margin-top: 10px;
}
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment