62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import { Container, Paper, Typography } from "@material-ui/core";
|
|
import React from "react";
|
|
import { makeStyles } from "@material-ui/core/styles";
|
|
import { useQuery } from "@apollo/client";
|
|
import {
|
|
GET_ALL_QUESTION_ANSWERS,
|
|
GetAllQuestionAnswersResponse,
|
|
GetAllQuestionAnswersVariables,
|
|
} from "../backend/queries/answer";
|
|
import { getJsonWebToken } from "../jwt/jwt";
|
|
import AccordionQuestionAnswer from "./AccordionQuestionAnswer";
|
|
import { CandidatePositionLegend } from "./CandidatePositionLegend";
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
container: {
|
|
paddingTop: theme.spacing(4),
|
|
paddingBottom: theme.spacing(4),
|
|
flexDirection: "column",
|
|
},
|
|
root: {
|
|
width: "100%",
|
|
padding: theme.spacing(1),
|
|
marginBottom: theme.spacing(3),
|
|
backgroundColor: theme.palette.background.default,
|
|
},
|
|
}));
|
|
|
|
interface MainPageCandidateProps {
|
|
personRowId: number;
|
|
}
|
|
|
|
export function MainPageCandidate(props: MainPageCandidateProps) {
|
|
const personRowId = getJsonWebToken()?.person_row_id;
|
|
const questionAnswers = useQuery<
|
|
GetAllQuestionAnswersResponse,
|
|
GetAllQuestionAnswersVariables
|
|
>(GET_ALL_QUESTION_ANSWERS, {
|
|
variables: {
|
|
personRowId,
|
|
},
|
|
}).data?.allQuestions.nodes;
|
|
const classes = useStyles();
|
|
|
|
return (
|
|
<Container maxWidth="lg" className={classes.container}>
|
|
<Paper className={classes.root}>
|
|
<Typography component={"h2"} variant="h6" color="primary" gutterBottom>
|
|
Fragen
|
|
</Typography>
|
|
<CandidatePositionLegend />
|
|
{questionAnswers?.map((question) => (
|
|
<AccordionQuestionAnswer
|
|
key={question.rowId}
|
|
personRowId={props.personRowId}
|
|
question={question}
|
|
/>
|
|
))}
|
|
</Paper>
|
|
</Container>
|
|
);
|
|
}
|