From 54d0d10271d9023abdf59e1ff041c6eb087d67aa Mon Sep 17 00:00:00 2001 From: Pedro Senai Date: Wed, 14 Oct 2020 20:35:13 -0300 Subject: [PATCH] post coment, list event --- src/components/cpmCard.vue | 68 +++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/src/components/cpmCard.vue b/src/components/cpmCard.vue index ac7f45c..81bac53 100644 --- a/src/components/cpmCard.vue +++ b/src/components/cpmCard.vue @@ -2,7 +2,7 @@
@@ -53,6 +53,7 @@ {{ comment.user.name }} - {{ comment.comment }} +
@@ -116,37 +117,50 @@ export default { }, methods: { - createComent(param) { - if (!this.newComent) { - this.$toast.error("Verifique se existe algum campo vazio", "Atenção!", { - position: "topCenter", - }); - } else { - let body = { - comment: this.newComent, - }; - let eventId = param.id; - - // this.$http.post(this.url + `/comment/${eventId}`, body).then(resp => { - // console.log(resp) - // }) - - axios - .post(this.url + `/comment/${eventId}`, body) - .then((resp) => { - // console.log(resp) - }) - .catch((err) => { - this.$toast.error("Erro no registro!", "Putz", { - position: "topCenter", + ...mapActions({ + getEvents: 'FeedVuex/getEvents' + }), + + createComent(param) { + if (!this.newComent) { + this.$toast.error("Verifique se existe algum campo vazio", "Atenção!", { + position: "topCenter", }); - }); - } - }, + } else { + let body = { + comment: this.newComent, + }; + let eventId = param.id; + + // this.$http.post(this.url + `/comment/${eventId}`, body).then(resp => { + // console.log(resp) + // }) + + axios + .post(this.url + `/comment/${eventId}`, body) + .then((resp) => { + + if(resp.data != ''){ + this.getEvents() + this.newComent = '' + + this.$toast.success("evento comentado!", "💥", { + position: "topCenter", + }); + } + }) + .catch((err) => { + this.$toast.error("Erro no registro!", "Putz", { + position: "topCenter", + }); + }); + } + }, }, created() { // this.cardDataArray.push(this.cardData) + console.log("odsadiosaiodjsioajdiosajdiosa"); console.log(this.cardData.comments); }, };