50 lines
911 B
Vue
50 lines
911 B
Vue
|
<template>
|
||
|
<div>
|
||
|
<div v-if="recipe === null">
|
||
|
Loading...
|
||
|
</div>
|
||
|
<div v-else>
|
||
|
<recipe-show :recipe="recipe"></recipe-show>
|
||
|
</div>
|
||
|
|
||
|
<router-link :to="{name: 'edit_recipe', params: { id: recipeId }}">Edit</router-link>
|
||
|
<router-link to="/">Back</router-link>
|
||
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
|
||
|
import RecipeShow from "./RecipeShow";
|
||
|
import { mapState } from "vuex";
|
||
|
import api from "../lib/Api";
|
||
|
|
||
|
export default {
|
||
|
data: function () {
|
||
|
return {
|
||
|
recipe: null,
|
||
|
showNutrition: false
|
||
|
}
|
||
|
},
|
||
|
|
||
|
computed: {
|
||
|
...mapState({
|
||
|
recipeId: state => state.route.params.id,
|
||
|
})
|
||
|
},
|
||
|
|
||
|
created() {
|
||
|
this.loadResource(
|
||
|
api.getRecipe(this.recipeId)
|
||
|
.then(data => { this.recipe = data; return data; })
|
||
|
);
|
||
|
},
|
||
|
|
||
|
components: {
|
||
|
RecipeShow
|
||
|
}
|
||
|
}
|
||
|
|
||
|
</script>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
</style>
|