From 2a272668be164771c8702015c5454bd5655bb426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Trembeck=C3=BD?= Date: Sat, 23 Nov 2024 11:27:29 +0100 Subject: [PATCH] fix Matboj (#460) --- .../CompetitionPage/UpcomingOrCurrentEventInfo.tsx | 7 ++++--- src/types/api/competition.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/CompetitionPage/UpcomingOrCurrentEventInfo.tsx b/src/components/CompetitionPage/UpcomingOrCurrentEventInfo.tsx index 830e45ad..e69ba779 100644 --- a/src/components/CompetitionPage/UpcomingOrCurrentEventInfo.tsx +++ b/src/components/CompetitionPage/UpcomingOrCurrentEventInfo.tsx @@ -16,17 +16,18 @@ export const UpcomingOrCurrentEventInfo: FC<{event: Event; name: string; shortNa const upcomingEventDate = event ? formatDateTimeInterval(start, end) : null - const regStart = DateTime.fromISO(registration_link.start) - const regEnd = DateTime.fromISO(registration_link.end) + const regStart = registration_link && DateTime.fromISO(registration_link.start) + const regEnd = registration_link && DateTime.fromISO(registration_link.end) const now = DateTime.now() const registrationInfo = (() => { + if (!regStart || !regEnd) return '' if (now < regStart) return `Registrácia bude otvorená od ${regStart.toFormat(DateFormat.DATE_TIME)}` if (now < regEnd) return `Registrácia je otvorená do ${regEnd.toFormat(DateFormat.DATE_TIME)}` return `Registrácia bola ukončená` })() - const isRegistrationActive = regStart < now && regEnd > now + const isRegistrationActive = regStart && regEnd && regStart < now && regEnd > now return ( diff --git a/src/types/api/competition.ts b/src/types/api/competition.ts index d5fcc194..9b49660e 100644 --- a/src/types/api/competition.ts +++ b/src/types/api/competition.ts @@ -30,7 +30,7 @@ export interface Event { can_participate: boolean is_registered: boolean publication_set: Publication[] - registration_link: RegistrationLink + registration_link?: RegistrationLink location: string | null year: number | null school_year: string | null