Skip to content

Commit 4029771

Browse files
committed
feat(web): vote-commited-indicator-in-voting-history
1 parent 60cb52c commit 4029771

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

web/src/hooks/queries/useVotingHistory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const votingHistoryQuery = graphql(`
2727
}
2828
vote {
2929
... on ClassicVote {
30+
commited
3031
justification {
3132
choice
3233
reference

web/src/pages/Cases/CaseDetails/Voting/VotesDetails/AccordionTitle.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,22 @@ const VoteStatus: React.FC<{
4242
choice?: string;
4343
period: string;
4444
answers: Answer[];
45+
commited: boolean;
4546
isActiveRound: boolean;
46-
}> = ({ choice, period, answers, isActiveRound }) => {
47+
hiddenVotes: boolean;
48+
}> = ({ choice, period, answers, isActiveRound, commited, hiddenVotes }) => {
49+
if (hiddenVotes) {
50+
if (!commited && (isActiveRound ? ["vote", "appeal", "execution"].includes(period) : true))
51+
return <StyledLabel>Did not commit vote </StyledLabel>;
52+
53+
if (["evidence", "commit"].includes(period))
54+
return <StyledLabel>{commited ? "Vote committed" : "Pending vote commitment"}</StyledLabel>;
55+
}
56+
57+
// not voted
4758
if (isUndefined(choice) && (isActiveRound ? ["appeal", "execution"].includes(period) : true))
4859
return <StyledLabel>Did not vote</StyledLabel>;
60+
4961
return (
5062
<StyledLabel>
5163
{isUndefined(choice) ? "Pending Vote" : <StyledSmall>{getVoteChoice(parseInt(choice), answers)}</StyledSmall>}
@@ -60,14 +72,16 @@ const AccordionTitle: React.FC<{
6072
period: string;
6173
answers: Answer[];
6274
isActiveRound: boolean;
63-
}> = ({ juror, choice, voteCount, period, answers, isActiveRound }) => {
75+
commited: boolean;
76+
hiddenVotes: boolean;
77+
}> = ({ juror, choice, voteCount, period, answers, isActiveRound, commited, hiddenVotes }) => {
6478
return (
6579
<TitleContainer>
6680
<AddressContainer>
6781
<Identicon size="20" string={juror} />
6882
<StyledLabel variant="secondaryText">{shortenAddress(juror)}</StyledLabel>
6983
</AddressContainer>
70-
<VoteStatus {...{ choice, period, answers, isActiveRound }} />
84+
<VoteStatus {...{ choice, period, answers, isActiveRound, commited, hiddenVotes }} />
7185
<StyledLabel variant="secondaryPurple">
7286
{voteCount} vote{voteCount > 1 && "s"}
7387
</StyledLabel>

web/src/pages/Cases/CaseDetails/Voting/VotesDetails/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ interface IVotesAccordion {
9595
period: string;
9696
answers: Answer[];
9797
isActiveRound: boolean;
98+
hiddenVotes: boolean;
9899
}
99100

100-
const VotesAccordion: React.FC<IVotesAccordion> = ({ drawnJurors, period, answers, isActiveRound }) => {
101+
const VotesAccordion: React.FC<IVotesAccordion> = ({ drawnJurors, period, answers, isActiveRound, hiddenVotes }) => {
101102
const accordionItems = useMemo(() => {
102103
return drawnJurors
103104
.map((drawnJuror) =>
@@ -111,6 +112,8 @@ const VotesAccordion: React.FC<IVotesAccordion> = ({ drawnJurors, period, answer
111112
period={period}
112113
answers={answers}
113114
isActiveRound={isActiveRound}
115+
commited={Boolean(drawnJuror.vote.commited)}
116+
hiddenVotes={hiddenVotes}
114117
/>
115118
),
116119
body: (
@@ -124,7 +127,7 @@ const VotesAccordion: React.FC<IVotesAccordion> = ({ drawnJurors, period, answer
124127
: null
125128
)
126129
.filter((item) => item !== null);
127-
}, [drawnJurors, period, answers, isActiveRound]);
130+
}, [drawnJurors, period, answers, isActiveRound, hiddenVotes]);
128131

129132
return (
130133
<>
@@ -146,6 +149,8 @@ const VotesAccordion: React.FC<IVotesAccordion> = ({ drawnJurors, period, answer
146149
period={period}
147150
answers={answers}
148151
isActiveRound={isActiveRound}
152+
hiddenVotes={hiddenVotes}
153+
commited={Boolean(drawnJuror.vote?.commited)}
149154
/>
150155
</StyledCard>
151156
)

web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const VotingHistory: React.FC<{ arbitrable?: `0x${string}`; isQuestion: boolean
116116
period={disputeData?.dispute?.period}
117117
answers={answers}
118118
isActiveRound={localRounds?.length - 1 === currentTab}
119+
hiddenVotes={Boolean(disputeData?.dispute?.court.hiddenVotes)}
119120
/>
120121
</>
121122
) : (

0 commit comments

Comments
 (0)