diff --git a/frontend-react/src/components/plus/Voting.js b/frontend-react/src/components/plus/Voting.js new file mode 100644 index 000000000..6a54d5e82 --- /dev/null +++ b/frontend-react/src/components/plus/Voting.js @@ -0,0 +1,5 @@ +import React from "react" + +const Voting = () => {} + +export default Voting diff --git a/graphql-schemas/plus.js b/graphql-schemas/plus.js index cc7cc1ca9..bb4d52321 100644 --- a/graphql-schemas/plus.js +++ b/graphql-schemas/plus.js @@ -13,6 +13,7 @@ const typeDef = gql` plusInfo: PlusGeneralInfo hasAccess(discord_id: String!, server: String!): Boolean! suggestions: [Suggested!]! + usersForVoting: UsersForVoting! } extend type Mutation { @@ -86,6 +87,11 @@ const typeDef = gql` "Average of all scores of the voters for the month 0% to 100%" score: Float! } + + type UsersForVoting { + users: [User!]! + suggested: [Suggested!]! + } ` const resolvers = { @@ -137,6 +143,36 @@ const resolvers = { voting_ends: null, } }, + usersForVoting: async (root, args, ctx) => { + if (!ctx.user) throw new UserInputError("Not logged in") + if (!ctx.user.plus || !ctx.user.plus.membership_status) + throw new UserInputError("Not plus server member") + const plus_server = ctx.user.plus.membership_status + + const users = await User.find({ + $or: [ + { + "plus.membership_status": plus_server, + }, + + { "plus.vouch_status": plus_server }, + ], + }).catch(e => { + throw (new Error(), + { + error: e, + }) + }) + + const suggested = await Suggested.find({ plus_server }).catch(e => { + throw (new Error(), + { + error: e, + }) + }) + + return { users, suggested } + }, suggestions: (root, args, ctx) => { if (!ctx.user || !ctx.user.plus) return null const searchCriteria =