Skip to content

Commit

Permalink
Fix confirm modal answers
Browse files Browse the repository at this point in the history
  • Loading branch information
selankon committed Oct 22, 2024
1 parent b56bb95 commit 5af2740
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/Process/ConfirmVoteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const ConfirmVoteModal = ({ elections, answers }: QuestionsConfirmationPr
const canAbstain =
election.resultsType.name === ElectionResultsTypeNames.MULTIPLE_CHOICE &&
election.resultsType.properties.canAbstain
const eAnswers = answers[election.id]
return (
<>
<Flex
Expand Down Expand Up @@ -54,7 +55,7 @@ export const ConfirmVoteModal = ({ elections, answers }: QuestionsConfirmationPr
span: <Text as='span' fontWeight='bold' whiteSpace='nowrap' />,
}}
values={{
answer: q.choices[Number(answers[i])].title.default,
answer: q.choices[Number(eAnswers[i])].title.default,
number: i + 1,
}}
/>
Expand All @@ -68,9 +69,9 @@ export const ConfirmVoteModal = ({ elections, answers }: QuestionsConfirmationPr
}}
values={{
answers:
answers[0].length === 0
eAnswers[0].length === 0
? t('process.spreadsheet.confirm.blank_vote')
: answers[0]
: eAnswers[0]
.map((a: string) => q.choices[Number(a)].title.default)
.map((a: string) => `- ${a}`)
.join('<br />'),
Expand All @@ -83,12 +84,12 @@ export const ConfirmVoteModal = ({ elections, answers }: QuestionsConfirmationPr
</Box>
))}
</Flex>
{canAbstain && answers[0].length < election.voteType.maxCount! && (
{canAbstain && eAnswers[0].length < election.voteType.maxCount! && (
<Flex direction={'row'} py={2} gap={2} alignItems={'center'} color={'primary.main'}>
<IoWarningOutline />
<Text display='flex' flexDirection='column' gap={1}>
{t('process.spreadsheet.confirm.abstain_count', {
count: election.voteType.maxCount! - answers[0].length,
count: election.voteType.maxCount! - eAnswers[0].length,
})}
</Text>
</Flex>
Expand Down

0 comments on commit 5af2740

Please sign in to comment.