Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
selankon committed Aug 9, 2024
1 parent 00697a3 commit ec2718e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions packages/chakra-components/src/components/Election/Envelope.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useClient, useDatesLocale, useElection } from '@vocdoni/react-providers'
import { useDatesLocale, useElection } from '@vocdoni/react-providers'
import {
ElectionResultsTypeNames,
ElectionStatus,
Expand All @@ -21,8 +21,7 @@ export const Envelope = ({
votePackage: VotePackageType
} & ChakraProps) => {
const styles = useMultiStyleConfig('Envelope')
const { localize } = useClient()
const { election } = useElection()
const { election, localize } = useElection()
const locale = useDatesLocale()

if (
Expand All @@ -49,7 +48,7 @@ export const Envelope = ({
return (
<chakra.div sx={styles.question}>
<Text sx={styles.title}>{localize('envelopes.question_title', { title: q.title.default })}</Text>
<ChoosedOptions question={q} questionIndex={i} votes={votePackage.votes} election={election} />
<ChoosedOptions question={q} questionIndex={i} votes={votePackage.votes} />
</chakra.div>
)
})}
Expand All @@ -58,25 +57,25 @@ export const Envelope = ({
}

const ChoosedOptions = ({
election,
question,
questionIndex,
votes,
}: {
election: PublishedElection
question: IQuestion
questionIndex: number
votes: number[]
}) => {
const { election, localize } = useElection()
const styles = useMultiStyleConfig('Envelope')
const { localize } = useClient()

if (!election || !(election instanceof PublishedElection)) return null

const selectedOptions: IChoice[] = []
switch (election.resultsType.name) {
case ElectionResultsTypeNames.MULTIPLE_CHOICE:
const abstainValues = election.resultsType?.properties?.abstainValues ?? []
let abstainCount = 0
votes.map((v) => {
votes.forEach((v) => {
if (abstainValues.includes(v.toString())) {
abstainCount++
return
Expand All @@ -94,7 +93,7 @@ const ChoosedOptions = ({
}
break
case ElectionResultsTypeNames.APPROVAL:
votes.map((v, i) => {
votes.forEach((v, i) => {
if (v > 0) selectedOptions.push(question.choices[i])
})
break
Expand Down
4 changes: 2 additions & 2 deletions packages/chakra-components/src/i18n/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const locales = {
},
empty: 'Apparently this process has no questions 🤔',
envelopes: {
envelope_abstain_count: 'Abstained times {{ count }}',
question_title: 'For question "{{ title }}" selected:',
envelope_abstain_count: 'Abstained {{ count }} times',
question_title: 'Option/s selected in "{{ title }}":',
},
errors: {
wrong_data_title: 'Wrong data',
Expand Down
2 changes: 1 addition & 1 deletion packages/chakra-components/src/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { EnvelopeTheme } from './envelope'

export const theme = {
components: {
EnvelopeTheme,
Envelope: EnvelopeTheme,
ElectionQuestions,
ElectionResults,
ElectionSchedule,
Expand Down

0 comments on commit ec2718e

Please sign in to comment.