From 1742230f043b43b5d994c216a0df4f2a4198c8a2 Mon Sep 17 00:00:00 2001 From: matushl Date: Sun, 24 Nov 2024 00:54:19 +0100 Subject: [PATCH] Redesign Competition Archive --- .../CompetitionPage/CompetitionPage.tsx | 51 +++++++++++-------- src/types/api/competition.ts | 2 +- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/components/CompetitionPage/CompetitionPage.tsx b/src/components/CompetitionPage/CompetitionPage.tsx index 9b54b563..6cd2dbc1 100644 --- a/src/components/CompetitionPage/CompetitionPage.tsx +++ b/src/components/CompetitionPage/CompetitionPage.tsx @@ -1,11 +1,12 @@ import {Stack, Typography} from '@mui/material' +import Grid from '@mui/material/Unstable_Grid2' import {useQuery} from '@tanstack/react-query' import axios from 'axios' import {useRouter} from 'next/router' -import {FC, useEffect} from 'react' +import {FC, Fragment, useEffect} from 'react' import {Link} from '@/components/Clickable/Link' -import {Competition, Event} from '@/types/api/competition' +import {Competition, Event, PublicationTypes} from '@/types/api/competition' import {BannerContainer} from '@/utils/BannerContainer' import {UpcomingOrCurrentEventInfo} from './UpcomingOrCurrentEventInfo' @@ -78,26 +79,36 @@ export const CompetitionPage: FC = ({ )} - - Archív - - {history_events.map((event) => ( - - - {name} {event.school_year} - - - {event.publication_set.map((publication) => ( - - {publication.name} + + {history_events.map((event) => { + const results = event.publication_set.find((p) => p.publication_type === PublicationTypes.RESULTS.id) + const problems = event.publication_set.find((p) => p.publication_type === PublicationTypes.PROBLEMS.id) + return ( + + + + {name} {event.school_year} + + + + {results && ( + + {results.name} - ))} - - - ))} - - + )} + + + {problems && ( + + {problems.name} + + )} + + + ) + })} + ) } diff --git a/src/types/api/competition.ts b/src/types/api/competition.ts index 42ab37df..4cf41f75 100644 --- a/src/types/api/competition.ts +++ b/src/types/api/competition.ts @@ -24,7 +24,7 @@ export const PublicationTypes = { }, RESULTS: { id: 1, - name: 'Výsledky', + name: 'Poradia', }, SOLUTIONS: { id: 2,