Skip to content

Commit

Permalink
Ask audience to email candidate if no answers
Browse files Browse the repository at this point in the history
  • Loading branch information
tewson committed Mar 19, 2024
1 parent f58a28e commit 780875b
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/pages/candidates/[candidate].astro
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export async function getStaticPaths() {
};
});
const hasAnswers = questions.some((question) =>
question.answers.some((answer) => Boolean(answer.answer))
);
return {
params: {
candidate: lodash.kebabCase(candidateFullName),
Expand All @@ -100,6 +104,7 @@ export async function getStaticPaths() {
candidateAreaName,
candidateAreaLocalAuthorityName,
questions,
hasAnswers,
},
};
});
Expand All @@ -110,6 +115,7 @@ const {
candidateAreaName,
candidateAreaLocalAuthorityName,
questions,
hasAnswers,
} = Astro.props;
---

Expand All @@ -127,14 +133,22 @@ const {
</HeaderSection>
<main class="px-gutter">
{
questions.map((question) => (
<>
<QuestionText>{question.text}</QuestionText>
{question.answers.map((answer) => (
<p class="pb-2">{answer.answer}</p>
))}
</>
))
hasAnswers ? (
questions.map((question) => (
<>
<QuestionText>{question.text}</QuestionText>
{question.answers.map((answer) => (
<p class="pb-2">{answer.answer}</p>
))}
</>
))
) : (
<p>
If you're a voter in this candidate's area and you'd like them to
answer these questions, please email them and tell them this:
&lt;[email protected]&gt;.
</p>
)
}
</main>
</Layout>

0 comments on commit 780875b

Please sign in to comment.