From 9ca805a99110d5521933b2a4b2a60c8691de82c8 Mon Sep 17 00:00:00 2001 From: taehoon Date: Mon, 25 Feb 2019 22:51:04 -0500 Subject: Add new FollowCard component --- src/components/follow_card/follow_card.js | 45 ++++++++++++++++++++++++++++++ src/components/follow_card/follow_card.vue | 40 ++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/components/follow_card/follow_card.js create mode 100644 src/components/follow_card/follow_card.vue (limited to 'src/components/follow_card') diff --git a/src/components/follow_card/follow_card.js b/src/components/follow_card/follow_card.js new file mode 100644 index 00000000..85e6a6d2 --- /dev/null +++ b/src/components/follow_card/follow_card.js @@ -0,0 +1,45 @@ +import BasicUserCard from '../basic_user_card/basic_user_card.vue' +import { requestFollow, requestUnfollow } from '../../services/follow_manipulate/follow_manipulate' + +const FollowCard = { + props: [ + 'user', + 'noFollowsYou' + ], + data () { + return { + progress: false, + requestSent: false, + updated: false + } + }, + components: { + BasicUserCard + }, + computed: { + isMe () { return this.$store.state.users.currentUser.id === this.user.id }, + following () { return this.updated ? this.updated.following : this.user.following }, + showFollow () { + return !this.following || this.updated && !this.updated.following + } + }, + methods: { + followUser () { + this.progress = true + requestFollow(this.user, this.$store).then(({ sent, updated }) => { + this.progress = false + this.requestSent = sent + this.updated = updated + }) + }, + unfollowUser () { + this.progress = true + requestUnfollow(this.user, this.$store).then(({ updated }) => { + this.progress = false + this.updated = updated + }) + } + } +} + +export default FollowCard diff --git a/src/components/follow_card/follow_card.vue b/src/components/follow_card/follow_card.vue new file mode 100644 index 00000000..dcb85d62 --- /dev/null +++ b/src/components/follow_card/follow_card.vue @@ -0,0 +1,40 @@ + + + -- cgit v1.2.3-70-g09d2 From 8923492e6824ad43731930dfc3b57dba45cc52e9 Mon Sep 17 00:00:00 2001 From: taehoon Date: Mon, 25 Feb 2019 22:57:40 -0500 Subject: Remove needless div wrapper --- src/components/follow_card/follow_card.vue | 52 ++++++++++++++---------------- 1 file changed, 25 insertions(+), 27 deletions(-) (limited to 'src/components/follow_card') diff --git a/src/components/follow_card/follow_card.vue b/src/components/follow_card/follow_card.vue index dcb85d62..936307c4 100644 --- a/src/components/follow_card/follow_card.vue +++ b/src/components/follow_card/follow_card.vue @@ -1,33 +1,31 @@