116 lines
2.5 KiB
JavaScript
116 lines
2.5 KiB
JavaScript
import gql from 'graphql-tag'
|
|
import possiblePositions from '@/app/euromat/possiblePositions'
|
|
|
|
export function getPositionById (id) {
|
|
return possiblePositions.find(option => option.id === id).position
|
|
}
|
|
|
|
export const apolloThesesQuery = gql`{
|
|
allQuestions(orderBy: ID_ASC) {
|
|
nodes {
|
|
category: categoryByCategoryId {
|
|
nodeId
|
|
title
|
|
}
|
|
text
|
|
id
|
|
nodeId
|
|
}
|
|
}
|
|
}`
|
|
|
|
export const apolloThesesUpdate = data => data.allQuestions.nodes.map(node => ({
|
|
id: node.id,
|
|
thesis: {
|
|
de: node.text
|
|
},
|
|
category: {
|
|
de: node.category.title
|
|
}
|
|
}))
|
|
|
|
export const apolloThesesCountQuery = gql`{
|
|
allQuestions {
|
|
totalCount
|
|
}
|
|
}`
|
|
|
|
export const apolloThesesCountUpdate = data => data.allQuestions.totalCount
|
|
|
|
export const apolloPersonsForResultsQuery = gql`{
|
|
allPeople(condition: {role: CANDYMAT_CANDIDATE}) {
|
|
nodes {
|
|
nodeId
|
|
firstName
|
|
lastName
|
|
id
|
|
answersByPersonId {
|
|
nodes {
|
|
nodeId
|
|
position
|
|
questionId
|
|
text
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`
|
|
|
|
export const apolloPersonsForResultsUpdate = data => data.allPeople.nodes.map(person => ({
|
|
id: person.id,
|
|
name: `${person.firstName} ${person.lastName}`,
|
|
token: person.firstName.charAt(0) + person.lastName.charAt(0),
|
|
positions: person.answersByPersonId.nodes.map(answer => ({
|
|
thesis: answer.questionId,
|
|
position: getPositionById(answer.position),
|
|
statement: {
|
|
de: answer.text
|
|
}
|
|
}))
|
|
}))
|
|
|
|
export const apolloPersonPositionsQuery = gql`
|
|
query Person($partyId: Int!) {
|
|
personById(id: $partyId) {
|
|
nodeId
|
|
id
|
|
firstName
|
|
lastName
|
|
answersByPersonId {
|
|
nodes {
|
|
nodeId
|
|
position
|
|
personId
|
|
text
|
|
questionByQuestionId {
|
|
nodeId
|
|
categoryByCategoryId {
|
|
nodeId
|
|
title
|
|
}
|
|
text
|
|
id
|
|
description
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}`
|
|
|
|
export const apolloPersonPositionsUpdate = data => ({
|
|
id: data.personById.id,
|
|
name: `${data.personById.firstName} ${data.personById.lastName}`,
|
|
token: data.personById.firstName.charAt(0) + data.personById.lastName.charAt(0),
|
|
theses: data.personById.answersByPersonId.nodes.map(answer => {
|
|
const question = answer.questionByQuestionId
|
|
return {
|
|
id: question.id,
|
|
thesis: question.text,
|
|
category: question.categoryByCategoryId.title,
|
|
position: getPositionById(answer.position),
|
|
statement: answer.text,
|
|
showStatement: false
|
|
}
|
|
})
|
|
})
|