You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
<template>
|
|
<div class="card">
|
|
<div class="card-block">
|
|
<p class="card-text">{{ comment.body }}</p>
|
|
</div>
|
|
<div class="card-footer">
|
|
<a href="" class="comment-author">
|
|
<img :src="comment.author.image" class="comment-author-img" />
|
|
</a>
|
|
<router-link
|
|
class="comment-author"
|
|
:to="{ name: 'profile', params: { username: comment.author.username } }"
|
|
>
|
|
{{ comment.author.username }}
|
|
</router-link>
|
|
<span class="date-posted">{{ comment.createdAt | date }}</span>
|
|
<span v-if="isCurrentUser" class="mod-options">
|
|
<i class="ion-trash-a" @click="destroy(slug, comment.id)"></i>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapGetters } from "vuex";
|
|
import { COMMENT_DESTROY } from "@/store/actions.type";
|
|
|
|
export default {
|
|
name: "RwvComment",
|
|
props: {
|
|
slug: { type: String, required: true },
|
|
comment: { type: Object, required: true }
|
|
},
|
|
computed: {
|
|
isCurrentUser() {
|
|
if (this.currentUser.username && this.comment.author.username) {
|
|
return this.comment.author.username === this.currentUser.username;
|
|
}
|
|
return false;
|
|
},
|
|
...mapGetters(["currentUser"])
|
|
},
|
|
methods: {
|
|
destroy(slug, commentId) {
|
|
this.$store.dispatch(COMMENT_DESTROY, { slug, commentId });
|
|
}
|
|
}
|
|
};
|
|
</script>
|