Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<script>
import {API} from "@/util/API";
export default {
name: "RecipeView",
data() {
return {
recipe: {},
id: this.$route.params.id,
title: "",
description: "",
time: "",
ingredients: [],
instructions: "",
}
},
methods: {
async loadData() {
await API.getRecipe(this.id)
.then((recipe) => {
this.title = recipe.title;
this.description = recipe.description;
this.time = recipe.time;
this.ingredients = recipe.ingredient;
this.instructions = recipe.instructions;
})
},
addIngredientsShoppingList() {
//TODO add ingredients to shopping list
},
removeIngredientsFromFridge() {
//TODO remove used ingredients from fridge
}
},
async mounted() {
await this.loadData();
}
}
</script>
<template>
<main>
<h1>{{this.title}}</h1><br>
<p>{{this.description}}</p><br>
<div class="ingredients">
<h2>Ingredienser</h2>
<ul>
<li v-for="ingredient in this.ingredients">{{ ingredient.item.name }} {{ ingredient.amount.quantity }} {{ingredient.amount.unit}}</li>
</ul>
<button @click="addIngredientsShoppingList">Legg til ingrediensene i handlekurven</button>
</div>
<div class="instructions">
<h2>Instruksjoner</h2>
{{this.instructions}}
</div>
<button @click="removeIngredientsFromFridge">Fjern varene fra kjøleskapet</button>
</main>
</template>
<style scoped lang="scss">
@media(min-width: base.$desktop-min) {
main {
padding-top: 45px !important;
}
}
main {
padding: 20px 10px;
.ingredients {
margin-bottom: 20px;
}
button {
min-height: 40px;
border-radius: 0;
border: 1px solid;
cursor: pointer;
padding: 5px;
}
}
</style>