From b60d5e6afdf3014ee89cc6d5280d68e7366916fd Mon Sep 17 00:00:00 2001 From: jordan Date: Sun, 16 Jun 2024 16:00:41 -0700 Subject: [PATCH] fix disappeaering vote results when not logged in --- src/components/voting/VoteResultsPanel.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/voting/VoteResultsPanel.tsx b/src/components/voting/VoteResultsPanel.tsx index 40dd6dd8..bb89ec16 100644 --- a/src/components/voting/VoteResultsPanel.tsx +++ b/src/components/voting/VoteResultsPanel.tsx @@ -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 }; });