-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ask audience to email candidate if no answers
- Loading branch information
Showing
1 changed file
with
22 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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), | ||
|
@@ -100,6 +104,7 @@ export async function getStaticPaths() { | |
candidateAreaName, | ||
candidateAreaLocalAuthorityName, | ||
questions, | ||
hasAnswers, | ||
}, | ||
}; | ||
}); | ||
|
@@ -110,6 +115,7 @@ const { | |
candidateAreaName, | ||
candidateAreaLocalAuthorityName, | ||
questions, | ||
hasAnswers, | ||
} = Astro.props; | ||
--- | ||
|
||
|
@@ -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: | ||
<[email protected]>. | ||
</p> | ||
) | ||
} | ||
</main> | ||
</Layout> |