Skip to content

Commit

Permalink
fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Matushl committed Nov 16, 2023
1 parent 99feb11 commit 4a7eade
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/components/CompetitionPage/CompetitionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ import {useRouter} from 'next/router'
import {FC, Fragment} from 'react'

import {Link} from '@/components/Clickable/Clickable'
import {Competition, Event} from '@/types/api/generated/competition'
import {Competition, Event} from '@/types/api/competition'
import {BannerContainer} from '@/utils/BannerContainer'
import {formatDate} from '@/utils/formatDate'

import styles from './competition.module.scss'

// TODO: skusime to opravit v API - `history_events` je nespravne vygenerovane ako `any`
type OurCompetition = Omit<Competition, 'history_events'> & {history_events: Event[]}

type CompetitionPageProps = {
Expand All @@ -20,9 +19,9 @@ export const CompetitionPage: FC<CompetitionPageProps> = ({
}) => {
const {setBannerText} = BannerContainer.useContainer()

const startDate = formatDate(upcoming_or_current_event?.start)
const endDate = formatDate(upcoming_or_current_event?.end)
setBannerText(upcoming_or_current_event ? `${name} sa bude konať ${startDate}` : '')
const startDate = upcoming_or_current_event ? formatDate(upcoming_or_current_event.start) : null
const endDate = upcoming_or_current_event ? formatDate(upcoming_or_current_event.end) : null
setBannerText(startDate ? `${name} sa bude konať ${startDate}` : '')

const router = useRouter()
const rulesLink = `${router.asPath}/pravidla`
Expand All @@ -39,8 +38,8 @@ export const CompetitionPage: FC<CompetitionPageProps> = ({
<p>
<b>Nadchádzajúci ročník:</b>
</p>
{upcoming_or_current_event.start && <p>Odkedy? {startDate} </p>}
{upcoming_or_current_event.end && <p>Dokedy? {endDate}</p>}
{startDate && <p>Odkedy? {startDate} </p>}
{endDate && <p>Dokedy? {endDate}</p>}
{upcoming_or_current_event.publication_set.length > 0 && (
<p>
<Link href={`/api/${upcoming_or_current_event.publication_set[0].file}`}>Pozvánka</Link>
Expand Down Expand Up @@ -77,7 +76,7 @@ export const CompetitionPage: FC<CompetitionPageProps> = ({
<h2>Archív: </h2>
</div>
{/* TODO: asi zjednotit styly, neriesit with/without publications */}
{competition_type.name === 'Tábor' ? (
{competition_type?.name === 'Tábor' ? (
<div className={styles.archiveWithoutPublications}>
{history_events.map((event) => (
<Fragment key={event.id}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/StaticSites/Texts.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
}

.p {
padding-bottom: 1rem;
margin: 1rem 0;
}

0 comments on commit 4a7eade

Please sign in to comment.