diff options
| author | jared <jaredrmain@gmail.com> | 2019-04-16 10:13:26 -0400 |
|---|---|---|
| committer | taehoon <th.dev91@gmail.com> | 2019-07-10 21:01:07 -0400 |
| commit | d5e8315e83327c7b8dda71eca5dd1c9d7d0a23dc (patch) | |
| tree | 9c73e4d96dd67de137c28132afba2fd7bf0c31a0 /src/components/subscribe_button | |
| parent | f2c95f9d0bcb9fd6640d8c5d38ce6fff111b70df (diff) | |
#482 - add subscribe button
Diffstat (limited to 'src/components/subscribe_button')
| -rw-r--r-- | src/components/subscribe_button/subscribe_button.js | 26 | ||||
| -rw-r--r-- | src/components/subscribe_button/subscribe_button.vue | 22 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/components/subscribe_button/subscribe_button.js b/src/components/subscribe_button/subscribe_button.js new file mode 100644 index 00000000..e3a2842c --- /dev/null +++ b/src/components/subscribe_button/subscribe_button.js @@ -0,0 +1,26 @@ +export default { + props: [ 'user' ], + data () { + return { + inProgress: false + } + }, + methods: { + subscribe () { + this.inProgress = true + this.$store.state.api.backendInteractor.subscribeUser(this.user.id) + .then((updated) => { + console.log(updated) + this.inProgress = false + }) + }, + unsubscribe () { + this.inProgress = true + this.$store.state.api.backendInteractor.unsubscribeUser(this.user.id) + .then((updated) => { + console.log(updated) + this.inProgress = false + }) + } + } +} diff --git a/src/components/subscribe_button/subscribe_button.vue b/src/components/subscribe_button/subscribe_button.vue new file mode 100644 index 00000000..f7dd8c61 --- /dev/null +++ b/src/components/subscribe_button/subscribe_button.vue @@ -0,0 +1,22 @@ +<template> + <div> + <button + @click.prevent="subscribe" + class="btn btn-default follow-card-follow-button" + :disabled="inProgress" + v-if="!user.subscribing" + > + Subscribe + </button> + <button + @click.prevent="unsubscribe" + class="btn btn-default follow-card-follow-button pressed" + :disabled="inProgress" + v-else + > + Subscribing! + </button> + </div> +</template> + +<script src="./subscribe_button.js"></script> |
