diff --git a/pages/votes/[pid]/[[...tid]].tsx b/pages/votes/[pid]/[[...tid]].tsx index 43452c2..53d143b 100644 --- a/pages/votes/[pid]/[[...tid]].tsx +++ b/pages/votes/[pid]/[[...tid]].tsx @@ -45,7 +45,7 @@ export async function getServerSideProps({query: {pid, tid}, locale}) { return {notFound: true}; } - if (election.date_end && isEnded(election.date_end)) { + if (isEnded(election.date_end)) { const url = getUrl(RouteTypes.ENDED_VOTE, locale, electionRef) return { redirect: { diff --git a/services/utils.ts b/services/utils.ts index c3a7d57..21f10b6 100644 --- a/services/utils.ts +++ b/services/utils.ts @@ -31,7 +31,7 @@ export const displayRef = (ref: string): string => { }; export const isEnded = (date: string): boolean => { - console.log("IS ENDED", date) + if (!date) return false; const dateEnd = new Date(date); const now = new Date(); return +dateEnd < +now;