fix: loading ballot

pull/100/head
Pierre-Louis Guhur 1 year ago
parent f22549cf80
commit c72315ebec

@ -36,11 +36,11 @@ export async function getServerSideProps({query: {pid, tid}, locale}) {
const [election, ballot, translations] = await Promise.all([ const [election, ballot, translations] = await Promise.all([
getElection(electionRef), getElection(electionRef),
tid ? getBallot(tid) : new Response(null), tid ? getBallot(tid) : null,
serverSideTranslations(locale, ['resource']), serverSideTranslations(locale, ['resource']),
]); ]);
if ('msg' in election) { if ('message' in election) {
return {notFound: true}; return {notFound: true};
} }
@ -66,13 +66,14 @@ export async function getServerSideProps({query: {pid, tid}, locale}) {
if (description.randomOrder) { if (description.randomOrder) {
shuffle(election.candidates); shuffle(election.candidates);
} }
console.log("BALLOT", ballot)
return { return {
props: { props: {
...translations, ...translations,
election, election,
token: tid || null, token: tid || null,
previousBallot: ballot, previousBallot: ballot || null,
}, },
}; };
} }

@ -271,7 +271,7 @@ export const getBallot = async (
}); });
if (response.status != 200) { if (response.status != 200) {
return null; return {status: response.status, message: "Can not load this ballot"};
} }
const payload = await response.json(); const payload = await response.json();

Loading…
Cancel
Save