fix: bug ended election

pull/100/head
Pierre-Louis Guhur 1 year ago
parent cdbb92ca97
commit 407a67dd06

@ -45,7 +45,7 @@ export async function getServerSideProps({query: {pid, tid}, locale}) {
return {notFound: true};
}
if (isEnded(election.date_end)) {
if (election.date_end && isEnded(election.date_end)) {
const url = getUrl(RouteTypes.ENDED_VOTE, locale, electionRef)
return {
redirect: {
@ -148,7 +148,7 @@ const VoteBallot = ({election, token, previousBallot}: VoteInterface) => {
}
};
if (election.restricted) {
if (election.restricted && !token) {
const locale = getLocaleShort(router);
const url = getUrl(RouteTypes.RESTRICTED_VOTE, locale)
router.push(url);

@ -31,6 +31,7 @@ export const displayRef = (ref: string): string => {
};
export const isEnded = (date: string): boolean => {
console.log("IS ENDED", date)
const dateEnd = new Date(date);
const now = new Date();
return +dateEnd < +now;

Loading…
Cancel
Save