diff --git a/src/components/CompetitionPage/UpcomingOrCurrentEventInfo.tsx b/src/components/CompetitionPage/UpcomingOrCurrentEventInfo.tsx index e69ba779..00c44b08 100644 --- a/src/components/CompetitionPage/UpcomingOrCurrentEventInfo.tsx +++ b/src/components/CompetitionPage/UpcomingOrCurrentEventInfo.tsx @@ -2,7 +2,7 @@ import {Stack, Typography} from '@mui/material' import {DateTime} from 'luxon' import {FC} from 'react' -import {Event} from '@/types/api/competition' +import {Event, PublicationTypes} from '@/types/api/competition' import {DateFormat, formatDateTimeInterval} from '@/utils/formatDate' import {Link} from '../Clickable/Link' @@ -14,6 +14,10 @@ export const UpcomingOrCurrentEventInfo: FC<{event: Event; name: string; shortNa }) => { const {year, school_year, location, registration_link, publication_set, start, end} = event + const invitationFile = publication_set.find( + (publication) => publication.publication_type === PublicationTypes.INVITATION.id, + ) + const upcomingEventDate = event ? formatDateTimeInterval(start, end) : null const regStart = registration_link && DateTime.fromISO(registration_link.start) @@ -42,8 +46,8 @@ export const UpcomingOrCurrentEventInfo: FC<{event: Event; name: string; shortNa {registrationInfo} - {publication_set.length > 0 && ( - + {invitationFile && ( + Pozvánka )} diff --git a/src/components/PublicationUploader/PublicationUploader.tsx b/src/components/PublicationUploader/PublicationUploader.tsx index 2b04487e..8a63d729 100644 --- a/src/components/PublicationUploader/PublicationUploader.tsx +++ b/src/components/PublicationUploader/PublicationUploader.tsx @@ -2,6 +2,7 @@ import {Stack, Typography} from '@mui/material' import {useQueryClient} from '@tanstack/react-query' import {FC} from 'react' +import {PublicationTypes} from '@/types/api/competition' import {SemesterWithProblems} from '@/types/api/generated/competition' import {Link} from '../Clickable/Link' @@ -19,7 +20,7 @@ export const PublicationUploader: FC = ({semesterId, o const refetch = () => queryClient.invalidateQueries({queryKey: ['competition', 'semester', semesterId]}) const appendFormData = (formData: FormData) => { - formData.append('publication_type', 'Časopisy') + formData.append('publication_type', PublicationTypes.LEAFLET.name) formData.append('event', semesterId.toString()) formData.append('order', order.toString()) } diff --git a/src/types/api/competition.ts b/src/types/api/competition.ts index 9b49660e..42ab37df 100644 --- a/src/types/api/competition.ts +++ b/src/types/api/competition.ts @@ -16,6 +16,30 @@ export interface Publication { order: number | null } +// webstrom-backend/competition/fixtures/publication_type.json +export const PublicationTypes = { + PROBLEMS: { + id: 0, + name: 'Zadania', + }, + RESULTS: { + id: 1, + name: 'Výsledky', + }, + SOLUTIONS: { + id: 2, + name: 'Brožúra', + }, + INVITATION: { + id: 3, + name: 'Pozvánka', + }, + LEAFLET: { + id: 4, + name: 'Časopisy', + }, +} + export interface RegistrationLink { id: number url: string