diff --git a/src/status/AcceptedVotes.tsx b/src/status/AcceptedVotes.tsx index 02a52557..fe214263 100644 --- a/src/status/AcceptedVotes.tsx +++ b/src/status/AcceptedVotes.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/router' import { Fragment, useEffect, useState } from 'react' import { CipherStrings } from 'src/crypto/stringify-shuffle' import { EncryptedVote } from 'src/protocol/EncryptedVote' -import { defaultRankingsAllowed } from 'src/vote/RankedChoiceItem' +import { defaultRankingsAllowed } from 'src/vote/Ballot' import { Item } from '../vote/storeElectionInfo' import { TotalVotesCast } from './TotalVotesCast' diff --git a/src/status/DecryptedVotes.tsx b/src/status/DecryptedVotes.tsx index bdeddd9a..1333770d 100644 --- a/src/status/DecryptedVotes.tsx +++ b/src/status/DecryptedVotes.tsx @@ -1,6 +1,6 @@ import { orderBy } from 'lodash-es' import { flatten } from 'lodash-es' -import { defaultRankingsAllowed } from 'src/vote/RankedChoiceItem' +import { defaultRankingsAllowed } from 'src/vote/Ballot' import { unTruncateSelection } from './un-truncate-selection' import { useDecryptedVotes } from './use-decrypted-votes' diff --git a/src/vote/Ballot.tsx b/src/vote/Ballot.tsx index b275cc8e..904baa77 100644 --- a/src/vote/Ballot.tsx +++ b/src/vote/Ballot.tsx @@ -11,6 +11,7 @@ import { State } from './vote-state' // Calculate maximum write-in string length const verification_num_length = 15 export const max_string_length = maxLength - verification_num_length +export const defaultRankingsAllowed = 3 export const Ballot = ({ dispatch, @@ -64,6 +65,7 @@ export const Ballot = ({ {...{ ...item, dispatch, + rankings_allowed: Math.min(defaultRankingsAllowed, max_options), state, }} key={index} diff --git a/src/vote/RankedChoiceItem.tsx b/src/vote/RankedChoiceItem.tsx index 2b042bf3..6cda2d1d 100644 --- a/src/vote/RankedChoiceItem.tsx +++ b/src/vote/RankedChoiceItem.tsx @@ -6,21 +6,19 @@ 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 = defaultRankingsAllowed, + rankings_allowed, state, title, }: ItemType & { dispatch: Dispatch> election_id?: string - rankings_allowed?: number + rankings_allowed: number state: State }): JSX.Element => { // console.log(state.plaintext) diff --git a/src/vote/submitted/SubmittedScreen.tsx b/src/vote/submitted/SubmittedScreen.tsx index 4c08db2c..a39a6e45 100644 --- a/src/vote/submitted/SubmittedScreen.tsx +++ b/src/vote/submitted/SubmittedScreen.tsx @@ -3,7 +3,7 @@ import { flatten } from 'lodash-es' import Link from 'next/link' import { useEffect } from 'react' -import { defaultRankingsAllowed } from '../RankedChoiceItem' +import { defaultRankingsAllowed } from '../Ballot' import { State } from '../vote-state' import { DetailedEncryptionReceipt } from './DetailedEncryptionReceipt' import { EncryptedVote } from './EncryptedVote'