diff --git a/src/components/cpmCard.vue b/src/components/cpmCard.vue index 81bac53..7f224bc 100644 --- a/src/components/cpmCard.vue +++ b/src/components/cpmCard.vue @@ -52,7 +52,67 @@ avatar - {{ comment.user.name }} - {{ comment.comment }} + {{ comment.user.name }} - + + + {{ comment.comment }} + + + + {{ comment.comment }} + + +
+ + + +
+ + mdi-close + + + + mdi-send-circle-outline + +
+ +
+ + + + + + + {{ item.name }} {{ item.icon }} + + + + @@ -107,7 +167,14 @@ export default { data: () => ({ // cardDataArray: [], newComent: "", + updateInputComment: "", + selectedCommentId: "", + setUpdateinput: false, url: process.env.VUE_APP_BASE_URL, + commentOptions: [ + {name: "Editar", icon:"mdi-pencil", color:"orange"}, + {name: "Deletar", icon:"mdi-trash-can", color:"error"} + ] }), computed: { @@ -150,18 +217,74 @@ export default { } }) .catch((err) => { - this.$toast.error("Erro no registro!", "Putz", { + this.$toast.error("Erro ao tentar comentar no evento!", "Putz", { position: "topCenter", }); }); } }, + + sendUpdateComment(comentData){ + + let comentId = comentData.id + let body = { + comment:this.updateInputComment + } + axios.put(this.url + `/comment/${comentId}`, body) + .then(resp => { + console.log(resp) + if(resp.data != ''){ + this.getEvents() + this.setUpdateinput = false + this.$toast.success("Comentário alterado", "💥", { + position: "topCenter", + }); + } + }) + .catch((err) => { + this.$toast.error("Erro ao tentar alterar comentário!", "Putz", { + position: "topCenter", + }); + }); + }, + + commentAction(param, comentID){ + console.log(param) + if(param.name == "Editar"){ + this.updateComment(comentID) + }else if(param.name == "Deletar"){ + this.deleteComment(comentID) + } + }, + updateComment(comentParam){ + console.log(comentParam.id) + this.selectedCommentId = comentParam.id + this.setUpdateinput = true + }, + deleteComment(comentParam){ + + let comentId = comentParam.id + axios.delete(this.url + `/comment/${comentId}`) + .then(resp => { + console.log(resp) + if(resp.data != ''){ + this.getEvents() + + this.$toast.success("Comentário deletado", "💥", { + position: "topCenter", + }); + } + }) + .catch((err) => { + this.$toast.error("Erro ao tentar deletar comentário!", "Putz", { + position: "topCenter", + }); + }); + + }, }, created() { - // this.cardDataArray.push(this.cardData) - console.log("odsadiosaiodjsioajdiosajdiosa"); - console.log(this.cardData.comments); }, };