From 5e3ced0463976831254dc32abcdb8a3f1845e271 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Thu, 23 May 2024 23:11:03 +0200 Subject: [PATCH] Update contentu --- .../CompetitionPage/CompetitionPage.tsx | 38 +++++++++++++++---- src/types/api/competition.ts | 2 + 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/components/CompetitionPage/CompetitionPage.tsx b/src/components/CompetitionPage/CompetitionPage.tsx index 6539a884..c0c8272d 100644 --- a/src/components/CompetitionPage/CompetitionPage.tsx +++ b/src/components/CompetitionPage/CompetitionPage.tsx @@ -17,7 +17,15 @@ type CompetitionPageProps = { } export const CompetitionPage: FC = ({ - competition: {id, name, who_can_participate, description, upcoming_or_current_event, history_events}, + competition: { + id, + competition_type, + name, + who_can_participate, + description, + upcoming_or_current_event, + history_events, + }, }) => { const {setBannerMessages} = BannerContainer.useContainer() @@ -43,7 +51,7 @@ export const CompetitionPage: FC = ({ ? formatDateTimeInterval(upcoming_or_current_event.start, upcoming_or_current_event.end) : null - function getRegistartionInfo(registrationLink: RegistrationLink) { + function getRegistrationInfo(registrationLink: RegistrationLink | null) { if (!registrationLink) return `` if (DateTime.fromISO(registrationLink.start) > DateTime.now()) return `Registrácia bude otvorená od ${formatDateTime(registrationLink.start)}` @@ -51,6 +59,21 @@ export const CompetitionPage: FC = ({ return `Registrácia je otvorená do ${formatDateTime(registrationLink.end)}` return `Registrácia bola ukončená` } + + function getEventInfo(upcomingEvent: Event | null) { + if (competition_type?.short_name === 'súťaž') + return `${upcomingEvent?.year}. ročník súťaže ${name} sa bude konať ${upcomingEventDate} ${ + upcomingEvent?.location || '' + }. ` + else if (competition_type?.short_name === 'tábor') + return `${name} v roku ${upcomingEvent?.school_year?.split('/')[1]} sa bude konať ${upcomingEventDate} ${ + upcomingEvent?.location || '' + }.` + else if (competition_type?.short_name === 'seminár') + return `Aktuálne prebieha ${upcomingEvent?.year}. ročník seminára ${name}` + return '' + } + const isRegistrationActive = upcoming_or_current_event?.registration_link ? DateTime.fromISO(upcoming_or_current_event.registration_link.start) < DateTime.now() && DateTime.fromISO(upcoming_or_current_event.registration_link.end) > DateTime.now() @@ -59,8 +82,8 @@ export const CompetitionPage: FC = ({ return ( - {who_can_participate && `Súťaž je určená pre ${who_can_participate}.`} - {description && ` ${description}`} + {description && `${description}`} + {who_can_participate && ` Súťaž je určená pre ${who_can_participate}.`} = ({ - Nadchádzajúci ročník {upcoming_or_current_event ? ( - {upcoming_or_current_event?.year}. ročník súťaže {name} sa bude konať {upcomingEventDate} v Košiciach.{' '} - {getRegistartionInfo(upcoming_or_current_event.registration_link)} + {getEventInfo(upcoming_or_current_event)} + {getRegistrationInfo(upcoming_or_current_event.registration_link)} @@ -99,7 +121,7 @@ export const CompetitionPage: FC = ({ ) : ( - Pripravujeme + Ďalší ročník aktuálne pripravujeme )} diff --git a/src/types/api/competition.ts b/src/types/api/competition.ts index 7eabf92c..d5fcc194 100644 --- a/src/types/api/competition.ts +++ b/src/types/api/competition.ts @@ -31,6 +31,7 @@ export interface Event { is_registered: boolean publication_set: Publication[] registration_link: RegistrationLink + location: string | null year: number | null school_year: string | null season_code: number @@ -43,6 +44,7 @@ export interface Event { export interface CompetitionType { id: number name: string + short_name: string } export interface Competition {