Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update event dates to new BE format #220

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions src/pages/strom/akcie/[[...params]].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -19,40 +20,50 @@ type CompetitionPageProps = {
is_rules: boolean
}

const StaticPage: NextPage<CompetitionPageProps> = ({competition, is_rules}) => (
<PageLayout title={competition.name}>
const StaticPage: NextPage<CompetitionPageProps> = ({
competition: {
name,
rules,
who_can_participate,
description,
upcoming_or_current_event,
competition_type,
history_events,
},
is_rules,
}) => (
<PageLayout title={name}>
{is_rules ? (
<div className={styles.mainText}>{competition.rules && <Markdown content={competition.rules} />}</div>
<div className={styles.mainText}>{rules && <Markdown content={rules} />}</div>
) : (
<>
<div className={styles.mainText}>
{competition.who_can_participate && <p>Pre koho? {competition.who_can_participate}</p>}
<p>{competition.description}</p>
{who_can_participate && <p>Pre koho? {who_can_participate}</p>}
<p>{description}</p>
</div>
<div className={styles.mainText}>
{competition.upcoming_or_current_event ? (
{upcoming_or_current_event ? (
<div className={styles.mainText}>
<p>
<b>Nadchádzajúci ročník:</b>
</p>
{competition.upcoming_or_current_event.start && (
<p>Odkedy? {competition.upcoming_or_current_event.start} </p>
)}
{competition.upcoming_or_current_event.end && <p>Dokedy? {competition.upcoming_or_current_event.end}</p>}
{competition.upcoming_or_current_event.publication_set.length > 0 && (
{upcoming_or_current_event.start && <p>Odkedy? {formatDate(upcoming_or_current_event.start)} </p>}
{upcoming_or_current_event.end && <p>Dokedy? {formatDate(upcoming_or_current_event.end)}</p>}
{upcoming_or_current_event.publication_set.length > 0 && (
// TODO: vyplut vsetky publikacie
<p>
<Link href={`/api/${competition.upcoming_or_current_event.publication_set[0].file}`}>Pozvánka</Link>
<Link href={`/api/${upcoming_or_current_event.publication_set[0].file}`}>Pozvánka</Link>
</p>
)}
{competition.upcoming_or_current_event.registration_link && (
{upcoming_or_current_event.registration_link && (
<div>
<p>
Registrácia prebieha do:
{competition.upcoming_or_current_event.registration_link.end}
<Link href={competition.upcoming_or_current_event.registration_link.url}>Registračný formulár</Link>
{formatDate(upcoming_or_current_event.registration_link.end)}
<Link href={upcoming_or_current_event.registration_link.url}>Registračný formulár</Link>
</p>

<p>{competition.upcoming_or_current_event.registration_link.additional_info}</p>
<p>{upcoming_or_current_event.registration_link.additional_info}</p>
</div>
)}
</div>
Expand All @@ -74,22 +85,23 @@ const StaticPage: NextPage<CompetitionPageProps> = ({competition, is_rules}) =>
<div className={styles.h2}>
<h2>Archív: </h2>
</div>
{competition.competition_type.name === 'Tábor' ? (
{/* TODO: asi zjednotit styly, neriesit with/without publications */}
{competition_type.name === 'Tábor' ? (
<div className={styles.archiveWithoutPublications}>
{competition.history_events.map((event) => (
{history_events.map((event) => (
<Fragment key={event.id}>
<div>
{competition.name + ' '} {event.school_year}
{name + ' '} {event.school_year}
</div>
</Fragment>
))}
</div>
) : (
<div className={styles.archiveWithPublications}>
{competition.history_events.map((event) => (
{history_events.map((event) => (
<Fragment key={event.id}>
<div>
{competition.name} {event.school_year}
{name} {event.school_year}
</div>
{event.publication_set.map((publication) => (
<Link key={publication.id} href={`/api/${publication.file}`}>
Expand Down
3 changes: 3 additions & 0 deletions src/utils/formatDate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {DateTime} from 'luxon'

export const formatDate = (date: string) => DateTime.fromISO(date).toFormat('dd.MM.yyyy HH:mm')
Loading