Skip to content

Commit 2830e96

Browse files
committed
Update round results link placement
Move the results link below group links, style it by result availability, and use the shared LinkButton for the back link so button padding is consistent.
1 parent 23841b8 commit 2830e96

2 files changed

Lines changed: 51 additions & 16 deletions

File tree

src/containers/CompetitionRound/CompetitionRound.test.tsx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ jest.mock('react-i18next', () => ({
5757
return `Round ${options?.roundNumber}`;
5858
}
5959

60+
if (key === 'common.activityCodeToName.group') {
61+
return `Group ${options?.groupNumber}`;
62+
}
63+
6064
return key;
6165
},
6266
}),
@@ -89,7 +93,15 @@ const linkedRoundsCompetition = {
8993
cutoff: null,
9094
timeLimit: null,
9195
advancementCondition: null,
92-
results: [],
96+
results: [
97+
{
98+
personId: 1,
99+
ranking: 1,
100+
attempts: [],
101+
best: 1000,
102+
average: 1200,
103+
},
104+
],
93105
},
94106
{
95107
id: '333-r3',
@@ -195,9 +207,29 @@ describe('CompetitionRoundContainer', () => {
195207
it('links to results for the selected round', () => {
196208
renderRound('333-r2');
197209

198-
expect(screen.getByText('See Results')).toHaveAttribute(
199-
'href',
200-
'/competitions/TestComp2026/results/333-r2',
210+
const resultsLink = screen.getByText('See Results');
211+
212+
expect(resultsLink).toHaveAttribute('href', '/competitions/TestComp2026/results/333-r2');
213+
expect(screen.getByText('Group 1').compareDocumentPosition(resultsLink)).toBe(
214+
Node.DOCUMENT_POSITION_FOLLOWING,
201215
);
202216
});
217+
218+
it('uses shared button spacing for the back link', () => {
219+
renderRound('333-r2');
220+
221+
expect(screen.getByText('Back To Events')).toHaveClass('btn', 'btn-block');
222+
});
223+
224+
it('shows when the selected round has results', () => {
225+
renderRound('333-r2');
226+
227+
expect(screen.getByText('See Results')).toHaveClass('btn-green');
228+
});
229+
230+
it('shows a neutral results link when the selected round has no results yet', () => {
231+
renderRound('333-r3');
232+
233+
expect(screen.getByText('See Results')).toHaveClass('btn-light');
234+
});
203235
});

src/containers/CompetitionRound/CompetitionRound.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export function CompetitionRoundContainer({
6060
const rounds = roundActivies.filter((ra) => toRoundAttemptId(ra.activityCode) === roundId);
6161
const groups = rounds.flatMap((r) => r.childActivities);
6262
const uniqueGroupCodes = [...new Set(groups.map((g) => g.activityCode))];
63+
const hasResults = (round?.results.length ?? 0) > 0;
6364

6465
return (
6566
<Container>
@@ -79,14 +80,6 @@ export function CompetitionRoundContainer({
7980
</p>
8081
)}
8182
{round && <CutoffTimeLimitPanel round={round} />}
82-
{round && (
83-
<LinkButton
84-
to={`/competitions/${competitionId}/results/${roundId}`}
85-
title={t('competition.results.seeResults')}
86-
variant="light"
87-
LinkComponent={LinkComponent}
88-
/>
89-
)}
9083
</div>
9184
</div>
9285
<ul className="flex flex-col space-y-2 p-2">
@@ -111,12 +104,22 @@ export function CompetitionRoundContainer({
111104
);
112105
})}
113106
</ul>
107+
{round && (
108+
<div className="space-y-2 p-2">
109+
<LinkButton
110+
to={`/competitions/${competitionId}/results/${roundId}`}
111+
title={t('competition.results.seeResults')}
112+
variant={hasResults ? 'green' : 'light'}
113+
LinkComponent={LinkComponent}
114+
/>
115+
</div>
116+
)}
114117
<div className="p-2">
115-
<LinkComponent
118+
<LinkButton
116119
to={`/competitions/${competitionId}/events/`}
117-
className="my-1 flex w-full flex-row rounded-md border border-primary bg-primary p-2 px-1 hover-transition hover:bg-primary-strong group dark:text-gray-100">
118-
{t('competition.groups.backToEvents')}
119-
</LinkComponent>
120+
title={t('competition.groups.backToEvents')}
121+
LinkComponent={LinkComponent}
122+
/>
120123
</div>
121124
</Container>
122125
);

0 commit comments

Comments
 (0)