Skip to content

Commit

Permalink
fix #504: Improve event publication list
Browse files Browse the repository at this point in the history
  • Loading branch information
Matushl committed Nov 24, 2024
1 parent d08e2cb commit 20f342a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/CompetitionPage/CompetitionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const CompetitionPage: FC<CompetitionPageProps> = ({
<Grid container spacing={2}>
{history_events.map((event) => {
const results = event.publication_set.find((p) => p.publication_type === PublicationTypes.RESULTS.id)
const solutions = event.publication_set.find((p) => p.publication_type === PublicationTypes.SOLUTIONS.id)
const problems = event.publication_set.find((p) => p.publication_type === PublicationTypes.PROBLEMS.id)
return (
<Fragment key={event.id}>
Expand All @@ -94,15 +95,21 @@ export const CompetitionPage: FC<CompetitionPageProps> = ({
<Grid xs={2} display="flex" justifyContent="end">
{results && (
<Link variant="button2" key={results.id} href={`/api${results.file}`}>
{results.name}
{PublicationTypes.RESULTS.display_name}
</Link>
)}
</Grid>
<Grid xs={2} display="flex" justifyContent="end">
{problems && (
<Link variant="button2" key={problems.id} href={`/api${problems.file}`}>
{problems.name}
{solutions ? (
<Link variant="button2" key={solutions.id} href={`/api${solutions.file}`}>
{PublicationTypes.SOLUTIONS.display_name}
</Link>
) : (
problems && (
<Link variant="button2" key={problems.id} href={`/api${problems.file}`}>
{PublicationTypes.PROBLEMS.display_name}
</Link>
)
)}
</Grid>
</Fragment>
Expand Down
5 changes: 5 additions & 0 deletions src/types/api/competition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,27 @@ export const PublicationTypes = {
PROBLEMS: {
id: 0,
name: 'Zadania',
display_name: 'Zadania',
},
RESULTS: {
id: 1,
name: 'Poradia',
display_name: 'Poradie',
},
SOLUTIONS: {
id: 2,
name: 'Brožúra',
display_name: 'Brožúra',
},
INVITATION: {
id: 3,
name: 'Pozvánka',
display_name: 'Pozvánka',
},
LEAFLET: {
id: 4,
name: 'Časopisy',
display_name: 'Časopis',
},
}

Expand Down

0 comments on commit 20f342a

Please sign in to comment.