[CLEAR-36] Add button for adding recipe to history

This commit is contained in:
Gabriela Pałka 2020-01-08 10:56:02 +01:00
parent f1460b819f
commit a31e08f9c4

View File

@ -2,6 +2,14 @@
<div>
<Card>
<p slot="title">{{ name }}</p>
<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>
<Row style="padding-left: 10px; padding-right: 10px">
<Col span="8" style="text-align: left">
<span><b>Wartości odżywcze:</b></span>
@ -76,6 +84,23 @@
this.loading = false;
this.$Message.error('Błąd!');
});
},
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;
});
}
}
}