|
|
|
@ -26,6 +26,7 @@ import {getLocaleShort, isEnded} from '@services/utils';
|
|
|
|
|
import WaitingBallot from '@components/WaitingBallot';
|
|
|
|
|
import PatternedBackground from '@components/PatternedBackground';
|
|
|
|
|
import {useRouter} from 'next/router';
|
|
|
|
|
import TitleBar from '@components/ballot/TitleBar';
|
|
|
|
|
|
|
|
|
|
const shuffle = (array) => array.sort(() => Math.random() - 0.5);
|
|
|
|
|
|
|
|
|
@ -74,7 +75,7 @@ export async function getServerSideProps({query: {pid, tid}, locale}) {
|
|
|
|
|
...translations,
|
|
|
|
|
election,
|
|
|
|
|
token: tid || null,
|
|
|
|
|
previousBallot: ballot || null,
|
|
|
|
|
previousBallot: ballot && ballot.status != 404 ? ballot : null,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
@ -117,6 +118,8 @@ const VoteBallot = ({election, token, previousBallot}: VoteInterface) => {
|
|
|
|
|
const [payload, setPayload] = useState<BallotPayload | null>(null);
|
|
|
|
|
const [error, setError] = useState<ErrorPayload | null>(null);
|
|
|
|
|
|
|
|
|
|
console.log("previous ballot", previousBallot)
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: BallotTypes.ELECTION,
|
|
|
|
@ -163,11 +166,8 @@ const VoteBallot = ({election, token, previousBallot}: VoteInterface) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<form
|
|
|
|
|
className="w-100 flex-fill d-flex align-items-center"
|
|
|
|
|
onSubmit={handleSubmit}
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
>
|
|
|
|
|
<><TitleBar election={ballot.election} />
|
|
|
|
|
|
|
|
|
|
<Head>
|
|
|
|
|
<title>{election.name}</title>
|
|
|
|
|
|
|
|
|
@ -178,6 +178,11 @@ const VoteBallot = ({election, token, previousBallot}: VoteInterface) => {
|
|
|
|
|
content={t('common.application')}
|
|
|
|
|
/>
|
|
|
|
|
</Head>
|
|
|
|
|
<form
|
|
|
|
|
className="w-100 flex-fill d-flex align-items-center"
|
|
|
|
|
onSubmit={handleSubmit}
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
<Blur />
|
|
|
|
|
<div className="w-100 h-100 d-flex flex-column justify-content-center">
|
|
|
|
@ -186,6 +191,7 @@ const VoteBallot = ({election, token, previousBallot}: VoteInterface) => {
|
|
|
|
|
<ButtonSubmit />
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|