Skip to content

Commit

Permalink
fix disappeaering vote results when not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanlesich committed Jun 16, 2024
1 parent 6bfbd1a commit b60d5e6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/voting/VoteResultsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ export const VoteResultsPanel = ({
const theme = useMantineTheme();

const consolidated = useMemo(() => {
if (!ships || !userVotes || !contest) return [];
if (!ships || !contest) return [];

return ships.map((ship) => {
const shipChoice = contest?.choices.find((c) => c.shipId === ship.id);

const userVote = userVotes.find((v) => v.choice_id === shipChoice?.id);
const userVote = userVotes
? userVotes.find((v) => v.choice_id === shipChoice?.id)
: null;

return { ...ship, vote: userVote, choice: shipChoice };
});
Expand Down

0 comments on commit b60d5e6

Please sign in to comment.