Skip to content

Commit

Permalink
contest name formatting function
Browse files Browse the repository at this point in the history
  • Loading branch information
rissois committed Aug 2, 2024
1 parent d30fcf3 commit 48261b0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions react-ui/src/pages/analyzeVotes/AnalyzeVotes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function AnalyzeVotes() {

const numberOfEntries = Object.keys(entryAvg).length;
const usernames = useMemo(() => userAvg.map((ua) => ua.username), [userAvg]);
const formattedContest = (name, date) => `${name} (${format(parseISO(date), 'MMM yy')})`;

const handleMinimumSlider = (event, newValue) => {
setVoteMinimum(newValue);
Expand Down Expand Up @@ -166,21 +167,27 @@ function AnalyzeVotes() {
return <em>Loading...</em>;
}

return `${selected.name} (${format(parseISO(selected.date), 'MMM yy')})`;
return formattedContest(selected.name, selected.date);
}}
onChange={(event) => navigate(`/mod/analyze/${event.target.value.id}`)}
>
{contests.map((c) => (
<MenuItem key={c.id} value={c}>
{`${c.name} (${format(parseISO(c.date), 'MMM yy')})`}
{formattedContest(c.name, c.date)}
</MenuItem>
))}
</Select>
</Box>

{
!votes.length
? <Typography className={classes.sideBySide}>We don&apos;t have any votes for this contest yet. Please choose another contest.</Typography>
? (
<Typography
className={classes.sideBySide}
>
We don&apos;t have any votes for this contest yet. Please choose another contest.
</Typography>
)
: (
<>
<Box className={classes.sideBySide}>
Expand Down

0 comments on commit 48261b0

Please sign in to comment.