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