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
import Poll from '../models/poll.model' | |
export function create(data) { | |
return Poll.create(data) | |
} | |
export function findAll() { | |
return Poll.find().sort({ createdAt: -1 }) | |
} |
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> | |
<!-- ...html --> | |
</template> | |
<script> | |
// ... code | |
import { OPTION_VOTED, POLL_CREATED } from '@/gql/subscriptions/poll.subscriptions' | |
// ... code |
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
// ... code | |
export const POLL_CREATED = gql` | |
subscription PollCreated { | |
pollCreated { | |
id | |
title | |
description | |
options { | |
id |
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
// ... code | |
export const CREATE_POLL = gql` | |
mutation createPoll($poll: CreatePollInput!) { | |
createPoll(poll: $poll) { | |
id | |
} | |
} | |
`; |
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"> |
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> | |
<div> | |
<b-button @click="isModalVisible = true">Create Poll</b-button> | |
<b-modal | |
v-model="isModalVisible" | |
@ok="$emit('createPoll', pollForm)" | |
title="Create a new poll" | |
centered | |
> |
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> | |
<-- ...html --> | |
</template> | |
<script> | |
import { POLLS } from '@/gql/queries/poll.queries' | |
import { VOTE_ON_POLL } from '@/gql/mutations/poll.mutations' | |
import { OPTION_VOTED } from '@/gql/subscriptions/poll.subscriptions' | |
import SinglePoll from '@/components/SinglePoll.vue' |
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
import gql from 'graphql-tag' | |
export const OPTION_VOTED = gql` | |
subscription OptionVoted { | |
optionVoted { | |
id | |
votes | |
} | |
} | |
` |
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-card :title="poll.title" :sub-title="poll.description"> | |
<b-form-group> | |
<b-form-radio-group | |
@change="$emit('optionVote', $event)" | |
:id="`poll-options-${poll.id}`" | |
stacked | |
> | |
<!-- ...html --> | |
</template> |
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
import gql from 'graphql-tag' | |
export const VOTE_ON_POLL = gql` | |
mutation VoteOnPoll($optionId: ID!) { | |
voteOnPoll(optionId: $optionId) { | |
id | |
} | |
} | |
`; |