From 8a1f4d4ece936c1cde73b097cd6a215e22347aea Mon Sep 17 00:00:00 2001 From: AmsaleG Date: Mon, 8 Aug 2022 15:29:22 +0300 Subject: [PATCH] done with update --- .../components/amsale/AmsaleBlogList.vue | 10 +++++++--- .../components/amsale/AmsaleEditBlog.vue | 11 ++++++++--- starter-project-web-vue2/store/amsale.js | 2 -- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/starter-project-web-vue2/components/amsale/AmsaleBlogList.vue b/starter-project-web-vue2/components/amsale/AmsaleBlogList.vue index a399cf00..3f46bcca 100644 --- a/starter-project-web-vue2/components/amsale/AmsaleBlogList.vue +++ b/starter-project-web-vue2/components/amsale/AmsaleBlogList.vue @@ -28,7 +28,7 @@ - + mdi-pencil Edit @@ -55,6 +55,13 @@ export default { show: false, updatedBlog: {}, }), + computed: { + isAuthor() { + return this.$auth.loggedIn && this.blog.authorUserId + ? this.blog.authorUserId._id === this.$auth.user._id + : 'loading' + }, + }, created() { this.updatedBlog.title = this.blog.title @@ -63,9 +70,7 @@ export default { methods: { ...mapActions('amsale', ['editBlog']), onSave() { - console.log('from frontend', this.blog, this.$auth.user) this.editBlog({ blog: this.updatedBlog, id: this.blog._id }) - // this.$nuxt.refresh() this.snackbar = true window.location.reload() this.show = false diff --git a/starter-project-web-vue2/store/amsale.js b/starter-project-web-vue2/store/amsale.js index eb0855da..1c179ea0 100644 --- a/starter-project-web-vue2/store/amsale.js +++ b/starter-project-web-vue2/store/amsale.js @@ -7,7 +7,6 @@ const actions = { commit('setBlogs', response.data) }, async deleteBlog({ commit }, id) { - console.log('deleted id', id) await this.$axios.delete(`articles/${id}`) commit('deletedBlog', id) window.location.reload() @@ -17,7 +16,6 @@ const actions = { commit('newBlog', response.data) }, async editBlog({ commit }, { blog, id }) { - console.log(blog, id) const response = await this.$axios.patch(`articles/${id}`, blog) commit('editBlog', response.data) },