From 8a4f705f12ea32246593c75956698bc8d670a3b3 Mon Sep 17 00:00:00 2001 From: kovacspe Date: Sun, 12 Nov 2023 12:36:59 +0100 Subject: [PATCH 1/6] Add banner info --- src/components/PageLayout/Banner/Banner.tsx | 8 +- src/components/Problems/Problems.tsx | 18 ++- src/pages/_app.tsx | 13 +- src/pages/strom/akcie/[[...params]].tsx | 165 +++++++++++--------- src/utils/BannerContainer.tsx | 9 ++ 5 files changed, 126 insertions(+), 87 deletions(-) create mode 100644 src/utils/BannerContainer.tsx diff --git a/src/components/PageLayout/Banner/Banner.tsx b/src/components/PageLayout/Banner/Banner.tsx index 453bce9c..a9dc9182 100644 --- a/src/components/PageLayout/Banner/Banner.tsx +++ b/src/components/PageLayout/Banner/Banner.tsx @@ -1,16 +1,16 @@ import {FC} from 'react' import {Marquee} from '@/components/Marquee/Marquee' +import {BannerContainer} from '@/utils/BannerContainer' import styles from './Banner.module.scss' export const Banner: FC = () => { - const text = - 'Matboj sa uskutoční 15. októbra 2021 - Matboj sa uskutoční 15. októbra 2021 - Matboj sa uskutoční 15. októbra 2021' + const {bannerText} = BannerContainer.useContainer() return (
- -
{text}
+ +
{bannerText}
) diff --git a/src/components/Problems/Problems.tsx b/src/components/Problems/Problems.tsx index b1a4ac57..63217a37 100644 --- a/src/components/Problems/Problems.tsx +++ b/src/components/Problems/Problems.tsx @@ -1,13 +1,15 @@ import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' import axios from 'axios' import {useRouter} from 'next/router' -import {FC, useState} from 'react' +import {FC, useEffect, useState} from 'react' import {useInterval} from 'usehooks-ts' import {Button, Link} from '@/components/Clickable/Clickable' import {SeriesWithProblems} from '@/types/api/competition' import {Profile} from '@/types/api/personal' import {AuthContainer} from '@/utils/AuthContainer' +import {BannerContainer} from '@/utils/BannerContainer' +import {formatDate} from '@/utils/formatDate' import {useDataFromURL} from '@/utils/useDataFromURL' import {useHasPermissions} from '@/utils/useHasPermissions' @@ -29,6 +31,7 @@ export const Problems: FC = () => { const router = useRouter() const {isAuthed} = AuthContainer.useContainer() + const {setBannerText} = BannerContainer.useContainer() const {data} = useQuery({ queryKey: ['personal', 'profiles', 'myprofile'], @@ -78,6 +81,19 @@ export const Problems: FC = () => { const invalidateSeriesQuery = () => queryClient.invalidateQueries({queryKey: ['competition', 'series', id.seriesId]}) + useEffect(() => { + if (seriesData === undefined) { + setBannerText('') + } else { + const deadline = formatDate(seriesData.data.deadline) + if (seriesData?.data.can_submit) { + setBannerText(`Termín série: ${deadline}`) + } else { + setBannerText(`Séria je uzavretá.`) + } + } + }, [seriesData, setBannerText]) + const {mutate: registerToSemester} = useMutation({ mutationFn: (id: number) => axios.post(`/api/competition/event/${id}/register`), onSuccess: () => { diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index cb3c5dfe..6b52d86e 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -11,6 +11,7 @@ import {CookiesProvider} from 'react-cookie' import {theme} from '@/theme' import {AuthContainer} from '@/utils/AuthContainer' +import {BannerContainer} from '@/utils/BannerContainer' import {PageTitleContainer} from '@/utils/PageTitleContainer' const ReactQueryDevtools = dynamic( @@ -83,11 +84,13 @@ const MyApp: FC = ({Component, pageProps}) => { - - - - - + + + + + + + diff --git a/src/pages/strom/akcie/[[...params]].tsx b/src/pages/strom/akcie/[[...params]].tsx index 9b95393e..05853e44 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 {BannerContainer} from '@/utils/BannerContainer' import {formatDate} from '@/utils/formatDate' import {Seminar} from '@/utils/useSeminarInfo' @@ -31,91 +32,101 @@ const StaticPage: NextPage = ({ history_events, }, is_rules, -}) => ( - - {is_rules ? ( -
{rules && }
- ) : ( - <> -
- {who_can_participate &&

Pre koho? {who_can_participate}

} -

{description}

-
-
- {upcoming_or_current_event ? ( -
-

- Nadchádzajúci ročník: -

- {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 +}) => { + const startDate = formatDate(upcoming_or_current_event.start) + const endDate = formatDate(upcoming_or_current_event.end) + const {setBannerText} = BannerContainer.useContainer() + if (upcoming_or_current_event) { + setBannerText(`${name} sa bude konať ${startDate}`) + } else { + setBannerText('') + } + + return ( + + {is_rules ? ( +
{rules && }
+ ) : ( + <> +
+ {who_can_participate &&

Pre koho? {who_can_participate}

} +

{description}

+
+
+ {upcoming_or_current_event ? ( +

- Pozvánka + Nadchádzajúci ročník:

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

Odkedy? {startDate}

} + {upcoming_or_current_event.end &&

Dokedy? {endDate}

} + {upcoming_or_current_event.publication_set.length > 0 && (

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

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

+ Registrácia prebieha do: + {upcoming_or_current_event.registration_link.end} + Registračný formulár +

+ +

{upcoming_or_current_event.registration_link.additional_info}

+
+ )} +
+ ) : ( +

+ Nadchádzajúci ročník: Pripravujeme +

+ )} +
-

{upcoming_or_current_event.registration_link.additional_info}

-
- )} -
- ) : ( -

- Nadchádzajúci ročník: Pripravujeme -

- )} -
- -
-
-
- +
+
+
+ +
-
- -
-

Archív:

-
- {/* TODO: asi zjednotit styly, neriesit with/without publications */} - {competition_type.name === 'Tábor' ? ( -
- {history_events.map((event) => ( - -
- {name + ' '} {event.school_year} -
-
- ))} -
- ) : ( -
- {history_events.map((event) => ( - -
- {name} {event.school_year} -
- {event.publication_set.map((publication) => ( - - {publication.name} - - ))} -
- ))} + +
+

Archív:

- )} - - )} - -) + {/* TODO: asi zjednotit styly, neriesit with/without publications */} + {competition_type.name === 'Tábor' ? ( +
+ {history_events.map((event) => ( + +
+ {name + ' '} {event.school_year} +
+
+ ))} +
+ ) : ( +
+ {history_events.map((event) => ( + +
+ {name} {event.school_year} +
+ {event.publication_set.map((publication) => ( + + {publication.name} + + ))} +
+ ))} +
+ )} + + )} + + ) +} export default StaticPage diff --git a/src/utils/BannerContainer.tsx b/src/utils/BannerContainer.tsx new file mode 100644 index 00000000..21562279 --- /dev/null +++ b/src/utils/BannerContainer.tsx @@ -0,0 +1,9 @@ +import {useState} from 'react' +import {createContainer} from 'unstated-next' + +const useBannerText = () => { + const [bannerText, setBannerText] = useState('') + return {bannerText, setBannerText} +} + +export const BannerContainer = createContainer(useBannerText) From ca83125232bbf0fbc0fb06f82b4d5ddddb614526 Mon Sep 17 00:00:00 2001 From: matushl Date: Sun, 12 Nov 2023 15:16:33 +0100 Subject: [PATCH 2/6] Move PageTitleContainer into PageLayout --- src/components/PageLayout/PageLayout.tsx | 42 +++++++++---------- src/components/PageLayout/TopGrid/TopGrid.tsx | 11 +++-- src/pages/_app.tsx | 5 +-- src/utils/PageTitleContainer.tsx | 4 +- 4 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/components/PageLayout/PageLayout.tsx b/src/components/PageLayout/PageLayout.tsx index 4296df2d..003fac52 100644 --- a/src/components/PageLayout/PageLayout.tsx +++ b/src/components/PageLayout/PageLayout.tsx @@ -19,31 +19,27 @@ type PageLayoutProps = { // pre pouzitie len na seminarovych strankach a podstrankach - `/matik(/*)` // ked budeme potrebovat top-level stranky ako `/ina-stranka`, budeme musiet upravit, ako sa pracuje s `useSeminarInfo` export const PageLayout: FC = ({contentWidth = 2, title = '', children}) => { - const {pageTitle, setPageTitle} = PageTitleContainer.useContainer() - - useEffect(() => { - if (title !== '') setPageTitle(title) - }, [contentWidth, title, setPageTitle]) - return ( -
- - - -
- -
- {children} + +
+ + + +
+ +
+ {children} +
+
-
-
+ ) } diff --git a/src/components/PageLayout/TopGrid/TopGrid.tsx b/src/components/PageLayout/TopGrid/TopGrid.tsx index 120be81f..3248af4b 100644 --- a/src/components/PageLayout/TopGrid/TopGrid.tsx +++ b/src/components/PageLayout/TopGrid/TopGrid.tsx @@ -4,20 +4,19 @@ import {useRouter} from 'next/router' import {FC} from 'react' import {SemesterPicker} from '@/components/SemesterPicker/SemesterPicker' +import {PageTitleContainer} from '@/utils/PageTitleContainer' import {useSeminarInfo} from '@/utils/useSeminarInfo' import styles from './TopGrid.module.scss' -type TopGridProps = { - title: string -} - -export const TopGrid: FC = ({title}) => { +export const TopGrid: FC = () => { const {seminar} = useSeminarInfo() // z napr. `/matik/zadania(/*)` vytiahne `zadania` const page = useRouter().pathname.split('/')[2] + const {pageTitle} = PageTitleContainer.useContainer() + return (
@@ -31,7 +30,7 @@ export const TopGrid: FC = ({title}) => { Strom
-
{title}
+
{pageTitle}
{(page === 'zadania' || page === 'vysledky') && (
diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 6b52d86e..6489d3d6 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -12,7 +12,6 @@ import {CookiesProvider} from 'react-cookie' import {theme} from '@/theme' import {AuthContainer} from '@/utils/AuthContainer' import {BannerContainer} from '@/utils/BannerContainer' -import {PageTitleContainer} from '@/utils/PageTitleContainer' const ReactQueryDevtools = dynamic( () => import('@tanstack/react-query-devtools').then(({ReactQueryDevtools}) => ReactQueryDevtools), @@ -86,9 +85,7 @@ const MyApp: FC = ({Component, pageProps}) => { - - - + diff --git a/src/utils/PageTitleContainer.tsx b/src/utils/PageTitleContainer.tsx index 01c31d64..e20a2d42 100644 --- a/src/utils/PageTitleContainer.tsx +++ b/src/utils/PageTitleContainer.tsx @@ -1,8 +1,8 @@ import {useState} from 'react' import {createContainer} from 'unstated-next' -const usePageTitle = () => { - const [pageTitle, setPageTitle] = useState('') +const usePageTitle = (initial = '') => { + const [pageTitle, setPageTitle] = useState(initial) return {pageTitle, setPageTitle} } From 97a7074df953deef428bcbeb1bd7322822784f28 Mon Sep 17 00:00:00 2001 From: matushl Date: Mon, 13 Nov 2023 21:26:08 +0100 Subject: [PATCH 3/6] Move CompetitionPage into own component --- .../CompetitionPage/CompetitionPage.tsx | 108 +++++++++++++++ src/components/CompetitionPage/RulesPage.tsx | 17 +++ .../CompetitionPage}/competition.module.scss | 1 - .../competition.module.scss.d.ts | 0 src/pages/strom/akcie/[[...params]].tsx | 123 ++---------------- 5 files changed, 135 insertions(+), 114 deletions(-) create mode 100644 src/components/CompetitionPage/CompetitionPage.tsx create mode 100644 src/components/CompetitionPage/RulesPage.tsx rename src/{pages/strom/akcie => components/CompetitionPage}/competition.module.scss (98%) rename src/{pages/strom/akcie => components/CompetitionPage}/competition.module.scss.d.ts (100%) diff --git a/src/components/CompetitionPage/CompetitionPage.tsx b/src/components/CompetitionPage/CompetitionPage.tsx new file mode 100644 index 00000000..8a03f73b --- /dev/null +++ b/src/components/CompetitionPage/CompetitionPage.tsx @@ -0,0 +1,108 @@ +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 {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 & {history_events: Event[]} + +type CompetitionPageProps = { + competition: OurCompetition +} + +export const CompetitionPage: FC = ({ + competition: {name, who_can_participate, description, upcoming_or_current_event, competition_type, history_events}, +}) => { + 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 router = useRouter() + const rulesLink = `${router.asPath}/pravidla` + + return ( + <> +
+ {who_can_participate &&

Pre koho? {who_can_participate}

} +

{description}

+
+
+ {upcoming_or_current_event ? ( +
+

+ Nadchádzajúci ročník: +

+ {upcoming_or_current_event.start &&

Odkedy? {startDate}

} + {upcoming_or_current_event.end &&

Dokedy? {endDate}

} + {upcoming_or_current_event.publication_set.length > 0 && ( +

+ Pozvánka +

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

+ Registrácia prebieha do: + {upcoming_or_current_event.registration_link.end} + Registračný formulár +

+ +

{upcoming_or_current_event.registration_link.additional_info}

+
+ )} +
+ ) : ( +

+ Nadchádzajúci ročník: Pripravujeme +

+ )} +
+ +
+
+
+ Pravidlá +
+
+
+ +
+

Archív:

+
+ {/* TODO: asi zjednotit styly, neriesit with/without publications */} + {competition_type.name === 'Tábor' ? ( +
+ {history_events.map((event) => ( + +
+ {name + ' '} {event.school_year} +
+
+ ))} +
+ ) : ( +
+ {history_events.map((event) => ( + +
+ {name} {event.school_year} +
+ {event.publication_set.map((publication) => ( + + {publication.name} + + ))} +
+ ))} +
+ )} + + ) +} diff --git a/src/components/CompetitionPage/RulesPage.tsx b/src/components/CompetitionPage/RulesPage.tsx new file mode 100644 index 00000000..441f20fd --- /dev/null +++ b/src/components/CompetitionPage/RulesPage.tsx @@ -0,0 +1,17 @@ +import {FC} from 'react' + +import {Markdown} from '@/components/StaticSites/Markdown' +import {Competition} from '@/types/api/generated/competition' +import {BannerContainer} from '@/utils/BannerContainer' +import {formatDate} from '@/utils/formatDate' + +type RulesPageProps = Pick + +export const RulesPage: FC = ({name, rules, upcoming_or_current_event}) => { + const {setBannerText} = BannerContainer.useContainer() + + const startDate = formatDate(upcoming_or_current_event?.start) + setBannerText(upcoming_or_current_event ? `${name} sa bude konať ${startDate}` : '') + + return +} diff --git a/src/pages/strom/akcie/competition.module.scss b/src/components/CompetitionPage/competition.module.scss similarity index 98% rename from src/pages/strom/akcie/competition.module.scss rename to src/components/CompetitionPage/competition.module.scss index fdf921d4..7911683a 100644 --- a/src/pages/strom/akcie/competition.module.scss +++ b/src/components/CompetitionPage/competition.module.scss @@ -1,7 +1,6 @@ .mainText{ >p{ padding: 20px; - width: 1000px; } } diff --git a/src/pages/strom/akcie/competition.module.scss.d.ts b/src/components/CompetitionPage/competition.module.scss.d.ts similarity index 100% rename from src/pages/strom/akcie/competition.module.scss.d.ts rename to src/components/CompetitionPage/competition.module.scss.d.ts diff --git a/src/pages/strom/akcie/[[...params]].tsx b/src/pages/strom/akcie/[[...params]].tsx index 05853e44..8f7e6f2d 100644 --- a/src/pages/strom/akcie/[[...params]].tsx +++ b/src/pages/strom/akcie/[[...params]].tsx @@ -1,18 +1,12 @@ import axios from 'axios' import {GetServerSideProps, NextPage} from 'next' -import {useRouter} from 'next/router' -import {FC, Fragment} from 'react' -import {Link} from '@/components/Clickable/Clickable' +import {CompetitionPage} from '@/components/CompetitionPage/CompetitionPage' +import {RulesPage} from '@/components/CompetitionPage/RulesPage' import {PageLayout} from '@/components/PageLayout/PageLayout' -import {Markdown} from '@/components/StaticSites/Markdown' import {Competition, Event} from '@/types/api/generated/competition' -import {BannerContainer} from '@/utils/BannerContainer' -import {formatDate} from '@/utils/formatDate' import {Seminar} from '@/utils/useSeminarInfo' -import styles from './competition.module.scss' - // skusime to opravit v API - `history_events` je nespravne vygenerovane ako `any` type OurCompetition = Omit & {history_events: Event[]} @@ -21,108 +15,17 @@ type CompetitionPageProps = { is_rules: boolean } -const StaticPage: NextPage = ({ - competition: { - name, - rules, - who_can_participate, - description, - upcoming_or_current_event, - competition_type, - history_events, - }, - is_rules, -}) => { - const startDate = formatDate(upcoming_or_current_event.start) - const endDate = formatDate(upcoming_or_current_event.end) - const {setBannerText} = BannerContainer.useContainer() - if (upcoming_or_current_event) { - setBannerText(`${name} sa bude konať ${startDate}`) - } else { - setBannerText('') - } - +const StaticPage: NextPage = ({competition, is_rules}) => { return ( - + {is_rules ? ( -
{rules && }
+ ) : ( - <> -
- {who_can_participate &&

Pre koho? {who_can_participate}

} -

{description}

-
-
- {upcoming_or_current_event ? ( -
-

- Nadchádzajúci ročník: -

- {upcoming_or_current_event.start &&

Odkedy? {startDate}

} - {upcoming_or_current_event.end &&

Dokedy? {endDate}

} - {upcoming_or_current_event.publication_set.length > 0 && ( -

- Pozvánka -

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

- Registrácia prebieha do: - {upcoming_or_current_event.registration_link.end} - Registračný formulár -

- -

{upcoming_or_current_event.registration_link.additional_info}

-
- )} -
- ) : ( -

- Nadchádzajúci ročník: Pripravujeme -

- )} -
- -
-
-
- -
-
-
- -
-

Archív:

-
- {/* TODO: asi zjednotit styly, neriesit with/without publications */} - {competition_type.name === 'Tábor' ? ( -
- {history_events.map((event) => ( - -
- {name + ' '} {event.school_year} -
-
- ))} -
- ) : ( -
- {history_events.map((event) => ( - -
- {name} {event.school_year} -
- {event.publication_set.map((publication) => ( - - {publication.name} - - ))} -
- ))} -
- )} - + )}
) @@ -164,9 +67,3 @@ export const competitionBasedGetServerSideProps = } export const getServerSideProps = competitionBasedGetServerSideProps('strom') - -const RulesLink: FC = () => { - const router = useRouter() - const active = `${router.asPath}/pravidla` - return Pravidlá -} From 9509110cd0562da82ad97b90b62973a5258557c2 Mon Sep 17 00:00:00 2001 From: matushl Date: Mon, 13 Nov 2023 21:26:36 +0100 Subject: [PATCH 4/6] Add style to

in Markdown component --- src/components/StaticSites/Markdown.tsx | 3 ++- src/components/StaticSites/Texts.module.scss | 4 ++++ src/components/StaticSites/Texts.module.scss.d.ts | 1 + src/components/StaticSites/Texts.tsx | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/StaticSites/Markdown.tsx b/src/components/StaticSites/Markdown.tsx index 0559526d..bff84801 100644 --- a/src/components/StaticSites/Markdown.tsx +++ b/src/components/StaticSites/Markdown.tsx @@ -6,7 +6,7 @@ import rehypeKatex from 'rehype-katex' import remarkGfm from 'remark-gfm' import remarkMath from 'remark-math' -import {MarkdownLink, Table, Td, Th} from './Texts' +import {MarkdownLink, P, Table, Td, Th} from './Texts' type MarkdownProps = { content: string @@ -21,6 +21,7 @@ export const Markdown: FC = ({content}) => ( td: Td, a: MarkdownLink, table: Table, + p: P, }} > {content} diff --git a/src/components/StaticSites/Texts.module.scss b/src/components/StaticSites/Texts.module.scss index a07deceb..dca6773e 100644 --- a/src/components/StaticSites/Texts.module.scss +++ b/src/components/StaticSites/Texts.module.scss @@ -12,4 +12,8 @@ font-weight: bold; font-style: italic; text-transform: uppercase; +} + +.p { + padding-bottom: 1rem; } \ No newline at end of file diff --git a/src/components/StaticSites/Texts.module.scss.d.ts b/src/components/StaticSites/Texts.module.scss.d.ts index 6aa1d36f..aff0cd78 100644 --- a/src/components/StaticSites/Texts.module.scss.d.ts +++ b/src/components/StaticSites/Texts.module.scss.d.ts @@ -1,4 +1,5 @@ export type Styles = { + p: string table: string td: string th: string diff --git a/src/components/StaticSites/Texts.tsx b/src/components/StaticSites/Texts.tsx index ac1fc5d9..4c176612 100644 --- a/src/components/StaticSites/Texts.tsx +++ b/src/components/StaticSites/Texts.tsx @@ -13,3 +13,4 @@ export const MarkdownLink: FC = ({children, href}) => = ({children}) => {children} export const Td: FC = ({children}) => {children} export const Table: FC = ({children}) => {children}
+export const P: FC = ({children}) =>

{children}

From 99feb11540b6a55a1a4ce3560b51a18d3b9af26f Mon Sep 17 00:00:00 2001 From: matushl Date: Mon, 13 Nov 2023 21:27:24 +0100 Subject: [PATCH 5/6] Move BannerContainer into PayeLayout --- src/components/PageLayout/PageLayout.tsx | 39 +++++++++++++----------- src/pages/_app.tsx | 9 ++---- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/components/PageLayout/PageLayout.tsx b/src/components/PageLayout/PageLayout.tsx index 003fac52..2991dfcf 100644 --- a/src/components/PageLayout/PageLayout.tsx +++ b/src/components/PageLayout/PageLayout.tsx @@ -1,6 +1,7 @@ import clsx from 'clsx' -import {FC, ReactNode, useEffect} from 'react' +import {FC, ReactNode} from 'react' +import {BannerContainer} from '@/utils/BannerContainer' import {PageTitleContainer} from '@/utils/PageTitleContainer' import {Banner} from './Banner/Banner' @@ -21,25 +22,27 @@ type PageLayoutProps = { export const PageLayout: FC = ({contentWidth = 2, title = '', children}) => { return ( -
- - - -
- -
- {children} + +
+ + + +
+ +
+ {children} +
+
-
-
+ ) } diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 6489d3d6..f5be7762 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -11,7 +11,6 @@ import {CookiesProvider} from 'react-cookie' import {theme} from '@/theme' import {AuthContainer} from '@/utils/AuthContainer' -import {BannerContainer} from '@/utils/BannerContainer' const ReactQueryDevtools = dynamic( () => import('@tanstack/react-query-devtools').then(({ReactQueryDevtools}) => ReactQueryDevtools), @@ -83,11 +82,9 @@ const MyApp: FC = ({Component, pageProps}) => { - - - - - + + + From bb19442ec9ebd11667b36cdbd66ffa9ea95fc5a7 Mon Sep 17 00:00:00 2001 From: matushl Date: Thu, 16 Nov 2023 01:05:00 +0100 Subject: [PATCH 6/6] fix after review --- .../CompetitionPage/CompetitionPage.tsx | 15 +++++++-------- src/components/StaticSites/Texts.module.scss | 2 +- src/pages/strom/akcie/[[...params]].tsx | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/CompetitionPage/CompetitionPage.tsx b/src/components/CompetitionPage/CompetitionPage.tsx index 8a03f73b..f3915ea8 100644 --- a/src/components/CompetitionPage/CompetitionPage.tsx +++ b/src/components/CompetitionPage/CompetitionPage.tsx @@ -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 & {history_events: Event[]} type CompetitionPageProps = { @@ -20,9 +19,9 @@ export const CompetitionPage: FC = ({ }) => { 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` @@ -39,8 +38,8 @@ export const CompetitionPage: FC = ({

Nadchádzajúci ročník:

- {upcoming_or_current_event.start &&

Odkedy? {startDate}

} - {upcoming_or_current_event.end &&

Dokedy? {endDate}

} + {startDate &&

Odkedy? {startDate}

} + {endDate &&

Dokedy? {endDate}

} {upcoming_or_current_event.publication_set.length > 0 && (

Pozvánka @@ -77,7 +76,7 @@ export const CompetitionPage: FC = ({

Archív:

{/* TODO: asi zjednotit styly, neriesit with/without publications */} - {competition_type.name === 'Tábor' ? ( + {competition_type?.name === 'Tábor' ? (
{history_events.map((event) => ( diff --git a/src/components/StaticSites/Texts.module.scss b/src/components/StaticSites/Texts.module.scss index dca6773e..2e6417d0 100644 --- a/src/components/StaticSites/Texts.module.scss +++ b/src/components/StaticSites/Texts.module.scss @@ -15,5 +15,5 @@ } .p { - padding-bottom: 1rem; + margin: 1rem 0; } \ No newline at end of file diff --git a/src/pages/strom/akcie/[[...params]].tsx b/src/pages/strom/akcie/[[...params]].tsx index 8f7e6f2d..492d3857 100644 --- a/src/pages/strom/akcie/[[...params]].tsx +++ b/src/pages/strom/akcie/[[...params]].tsx @@ -4,10 +4,9 @@ import {GetServerSideProps, NextPage} from 'next' import {CompetitionPage} from '@/components/CompetitionPage/CompetitionPage' import {RulesPage} from '@/components/CompetitionPage/RulesPage' import {PageLayout} from '@/components/PageLayout/PageLayout' -import {Competition, Event} from '@/types/api/generated/competition' +import {Competition, Event} from '@/types/api/competition' import {Seminar} from '@/utils/useSeminarInfo' -// skusime to opravit v API - `history_events` je nespravne vygenerovane ako `any` type OurCompetition = Omit & {history_events: Event[]} type CompetitionPageProps = {