Created
May 29, 2019 23:03
-
-
Save LazyFatArrow/8585888ea0a28bbb19ad2b083ca92349 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<b-container class="my-5"> | |
<b-row> | |
<b-col> | |
<CreatePollModal | |
@createPoll="handleCreatePoll" | |
/> | |
</b-col> | |
</b-row> | |
<b-row class="mt-3" v-if="polls && polls.length"> | |
<b-col> | |
<b-card-group columns> | |
<SinglePoll | |
v-for="poll in polls" | |
@optionVote="handleOptionVote" | |
:key="`poll-${poll.id}`" | |
:poll="poll" | |
/> | |
</b-card-group> | |
</b-col> | |
</b-row> | |
</b-container> | |
</template> | |
<script> | |
import { POLLS } from '@/gql/queries/poll.queries' | |
import { VOTE_ON_POLL, CREATE_POLL } from '@/gql/mutations/poll.mutations' | |
import { OPTION_VOTED, POLL_CREATED } from '@/gql/subscriptions/poll.subscriptions' | |
import SinglePoll from '@/components/SinglePoll.vue' | |
import CreatePollModal from '@/components/CreatePollModal.vue' | |
export default { | |
// ... code | |
methods: { | |
// ... code | |
handleCreatePoll(pollForm) { | |
this.$apollo.mutate({ | |
mutation: CREATE_POLL, | |
variables: { | |
poll: pollForm, | |
}, | |
}) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment