2020-01-07 21:26:49 +01:00
|
|
|
<template>
|
2020-01-19 19:24:47 +01:00
|
|
|
<div v-if="loaded">
|
2020-01-07 21:26:49 +01:00
|
|
|
<Card>
|
|
|
|
<p slot="title">{{ name }}</p>
|
2020-01-08 10:56:02 +01:00
|
|
|
<Row type="flex" justify="right" style="margin-bottom: 10px;">
|
|
|
|
<Col span="8"/>
|
|
|
|
<Col span="8" offset="8">
|
|
|
|
<Button v-if="$auth.loggedIn" type="primary" @click="addToHistory">
|
|
|
|
Dodaj przepis do historii
|
|
|
|
</Button>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
2020-01-07 21:26:49 +01:00
|
|
|
<Row style="padding-left: 10px; padding-right: 10px">
|
|
|
|
<Col span="8" style="text-align: left">
|
|
|
|
<span><b>Wartości odżywcze:</b></span>
|
|
|
|
<ul>
|
|
|
|
<span>Kcal: {{nutrition.kcal}}</span>
|
|
|
|
</ul>
|
|
|
|
<ul>
|
|
|
|
<span>Węglowodany: {{nutrition.carbohydrates}}</span>
|
|
|
|
</ul>
|
|
|
|
<ul>
|
|
|
|
<span>Białka: {{nutrition.protein}}</span>
|
|
|
|
</ul>
|
|
|
|
<ul>
|
|
|
|
<span>Tłuszcze: {{nutrition.fat}}</span>
|
|
|
|
</ul>
|
|
|
|
<br/>
|
|
|
|
<span><b>Składniki:</b></span>
|
|
|
|
<ul>
|
|
|
|
<li v-for="item in ingredients">
|
|
|
|
<span>{{ item.name }}: {{ item.weight }}g</span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</Col>
|
|
|
|
<Col span="16" style="text-align: left">
|
|
|
|
<span><b>Opis:</b></span>
|
|
|
|
<p>{{ description }}</p>
|
|
|
|
<br/>
|
|
|
|
<span><b>Przygotowanie:</b></span>
|
|
|
|
<ul v-for="item in steps">
|
|
|
|
<span>{{ item }}</span>
|
|
|
|
</ul>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: "ShowRecipe",
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
name: '',
|
|
|
|
description: '',
|
|
|
|
ingredients: [],
|
|
|
|
steps: [],
|
2020-01-19 19:24:47 +01:00
|
|
|
loaded: false,
|
2020-01-07 21:26:49 +01:00
|
|
|
nutrition: {
|
|
|
|
kcal: 0,
|
|
|
|
carbohydrates: 0,
|
|
|
|
protein: 0,
|
|
|
|
fat: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.retrieveRecipe();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
retrieveRecipe() {
|
|
|
|
this.loading = true;
|
|
|
|
this.$axios.get(`/recipe/${this.$route.params.id}`)
|
|
|
|
.then((response) => {
|
|
|
|
const data = response.data.data.recipe;
|
|
|
|
this.name = data.name;
|
|
|
|
this.description = data.description;
|
|
|
|
this.ingredients = data.ingredients;
|
|
|
|
this.steps = data.steps;
|
|
|
|
this.nutrition = data.nutrition;
|
2020-01-19 19:24:47 +01:00
|
|
|
this.loaded = true;
|
2020-01-07 21:26:49 +01:00
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.log(error);
|
|
|
|
this.loading = false;
|
|
|
|
this.$Message.error('Błąd!');
|
|
|
|
});
|
2020-01-08 10:56:02 +01:00
|
|
|
},
|
|
|
|
success() {
|
|
|
|
this.$Notice.success({
|
|
|
|
title: 'Przepis został dodany do historii.',
|
|
|
|
desc: ''
|
|
|
|
});
|
|
|
|
},
|
|
|
|
addToHistory() {
|
|
|
|
this.$axios.post('/user/save-recipe', {recipeID: this.$route.params.id})
|
|
|
|
.then(() => {
|
|
|
|
this.success();
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
console.log(error);
|
|
|
|
this.$Message.error('Błąd!');
|
|
|
|
this.modal_loading = false;
|
|
|
|
});
|
2020-01-07 21:26:49 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
2020-01-19 19:24:47 +01:00
|
|
|
</style>
|