/vote submitted: respect type: 'ranked-choice-irv' in Unlocked & Encrypted widgets

This commit is contained in:
David Ernst
2023-07-18 20:23:36 -07:00
parent 9f13c87508
commit bbcfaf0fd5
2 changed files with 10 additions and 7 deletions

View File

@@ -6,13 +6,15 @@ import { Label, TitleDescriptionQuestion } from './Item'
import { Item as ItemType } from './storeElectionInfo'
import { State } from './vote-state'
export const defaultRankingsAllowed = 3
export const RankedChoiceItem = ({
description,
dispatch,
id = 'vote',
options,
question,
rankings_allowed = 4,
rankings_allowed = defaultRankingsAllowed,
state,
title,
}: ItemType & {

View File

@@ -3,6 +3,7 @@ import { flatten } from 'lodash-es'
import Link from 'next/link'
import { useEffect } from 'react'
import { defaultRankingsAllowed } from '../RankedChoiceItem'
import { State } from '../vote-state'
import { DetailedEncryptionReceipt } from './DetailedEncryptionReceipt'
import { EncryptedVote } from './EncryptedVote'
@@ -21,15 +22,15 @@ export function SubmittedScreen({
// Widen the page for the tables
useEffect(() => {
const mainEl = document.getElementsByTagName('main')[0]
if (mainEl) {
mainEl.style.maxWidth = '880px'
}
if (mainEl) mainEl.style.maxWidth = '880px'
})
const columns = flatten(
state.ballot_design?.map(({ id, multiple_votes_allowed }) => {
return multiple_votes_allowed
? new Array(multiple_votes_allowed).fill('').map((_, index) => `${id || 'vote'}_${index + 1}`)
state.ballot_design?.map(({ id, multiple_votes_allowed, type }) => {
return multiple_votes_allowed || type === 'ranked-choice-irv'
? new Array(multiple_votes_allowed || defaultRankingsAllowed)
.fill('')
.map((_, index) => `${id || 'vote'}_${index + 1}`)
: id || 'vote'
}),
)