Skip to content

Commit

Permalink
Empty respones message for area page
Browse files Browse the repository at this point in the history
  • Loading branch information
tewson committed Mar 19, 2024
1 parent 780875b commit 3a2f1df
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions src/pages/areas/[localAuthority]/[area].astro
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export async function getStaticPaths() {
};
});
const hasAnswers = questions.some((question) =>
question.answers.some((answer) => Boolean(answer.answer))
);
return {
params: {
localAuthority: lodash.kebabCase(
Expand All @@ -96,12 +100,13 @@ export async function getStaticPaths() {
props: {
area: electoralAreaName,
questions,
hasAnswers,
},
};
});
}
const { area, questions } = Astro.props;
const { area, questions, hasAnswers } = Astro.props;
---

<Layout>
Expand All @@ -110,23 +115,27 @@ const { area, questions } = Astro.props;
</HeaderSection>
<main class="px-gutter">
{
questions.map((question) => (
<>
<QuestionText>{question.text}</QuestionText>
{question.answers.map((answer) => (
<>
<h3>
<Link
to={`candidates/${lodash.kebabCase(answer.candidateFullName)}`}
>
{answer.candidateFullName}
</Link>
</h3>
<p>{answer.answer}</p>
</>
))}
</>
))
hasAnswers ? (
questions.map((question) => (
<>
<QuestionText>{question.text}</QuestionText>
{question.answers.map((answer) => (
<>
<h3>
<Link
to={`candidates/${lodash.kebabCase(answer.candidateFullName)}`}
>
{answer.candidateFullName}
</Link>
</h3>
<p>{answer.answer}</p>
</>
))}
</>
))
) : (
<p>No candidates in this area have provided answers yet.</p>
)
}
</main>
</Layout>

0 comments on commit 3a2f1df

Please sign in to comment.