26 lines
565 B
JavaScript
Executable File
26 lines
565 B
JavaScript
Executable File
import { Polls } from '/imports/api/polls';
|
|
import { callServer } from '/imports/ui/services/api';
|
|
|
|
let mapPolls = function () {
|
|
let poll = Polls.findOne({});
|
|
if (!poll) {
|
|
return { pollExists: false };
|
|
}
|
|
|
|
const amIRequester = poll.requester != 'userId';
|
|
|
|
return {
|
|
poll: {
|
|
answers: poll.poll.answers,
|
|
pollId: poll.poll.id,
|
|
},
|
|
pollExists: true,
|
|
amIRequester: amIRequester,
|
|
handleVote: function (pollId, answerId) {
|
|
callServer('publishVoteMessage', pollId, answerId.id);
|
|
},
|
|
};
|
|
};
|
|
|
|
export default { mapPolls };
|