diff --git a/src/pages/strom/akcie/[[...params]].tsx b/src/pages/strom/akcie/[[...params]].tsx index c515fb43..9b95393e 100644 --- a/src/pages/strom/akcie/[[...params]].tsx +++ b/src/pages/strom/akcie/[[...params]].tsx @@ -7,6 +7,7 @@ import {Link} from '@/components/Clickable/Clickable' import {PageLayout} from '@/components/PageLayout/PageLayout' import {Markdown} from '@/components/StaticSites/Markdown' import {Competition, Event} from '@/types/api/generated/competition' +import {formatDate} from '@/utils/formatDate' import {Seminar} from '@/utils/useSeminarInfo' import styles from './competition.module.scss' @@ -19,40 +20,50 @@ type CompetitionPageProps = { is_rules: boolean } -const StaticPage: NextPage = ({competition, is_rules}) => ( - +const StaticPage: NextPage = ({ + competition: { + name, + rules, + who_can_participate, + description, + upcoming_or_current_event, + competition_type, + history_events, + }, + is_rules, +}) => ( + {is_rules ? ( -
{competition.rules && }
+
{rules && }
) : ( <>
- {competition.who_can_participate &&

Pre koho? {competition.who_can_participate}

} -

{competition.description}

+ {who_can_participate &&

Pre koho? {who_can_participate}

} +

{description}

- {competition.upcoming_or_current_event ? ( + {upcoming_or_current_event ? (

Nadchádzajúci ročník:

- {competition.upcoming_or_current_event.start && ( -

Odkedy? {competition.upcoming_or_current_event.start}

- )} - {competition.upcoming_or_current_event.end &&

Dokedy? {competition.upcoming_or_current_event.end}

} - {competition.upcoming_or_current_event.publication_set.length > 0 && ( + {upcoming_or_current_event.start &&

Odkedy? {formatDate(upcoming_or_current_event.start)}

} + {upcoming_or_current_event.end &&

Dokedy? {formatDate(upcoming_or_current_event.end)}

} + {upcoming_or_current_event.publication_set.length > 0 && ( + // TODO: vyplut vsetky publikacie

- Pozvánka + Pozvánka

)} - {competition.upcoming_or_current_event.registration_link && ( + {upcoming_or_current_event.registration_link && (

Registrácia prebieha do: - {competition.upcoming_or_current_event.registration_link.end} - Registračný formulár + {formatDate(upcoming_or_current_event.registration_link.end)} + Registračný formulár

-

{competition.upcoming_or_current_event.registration_link.additional_info}

+

{upcoming_or_current_event.registration_link.additional_info}

)}
@@ -74,22 +85,23 @@ const StaticPage: NextPage = ({competition, is_rules}) =>

Archív:

- {competition.competition_type.name === 'Tábor' ? ( + {/* TODO: asi zjednotit styly, neriesit with/without publications */} + {competition_type.name === 'Tábor' ? (
- {competition.history_events.map((event) => ( + {history_events.map((event) => (
- {competition.name + ' '} {event.school_year} + {name + ' '} {event.school_year}
))}
) : (
- {competition.history_events.map((event) => ( + {history_events.map((event) => (
- {competition.name} {event.school_year} + {name} {event.school_year}
{event.publication_set.map((publication) => ( diff --git a/src/utils/formatDate.ts b/src/utils/formatDate.ts new file mode 100644 index 00000000..1375dbc7 --- /dev/null +++ b/src/utils/formatDate.ts @@ -0,0 +1,3 @@ +import {DateTime} from 'luxon' + +export const formatDate = (date: string) => DateTime.fromISO(date).toFormat('dd.MM.yyyy HH:mm')