Skip to content

Commit dc91d63

Browse files
authored
Merge pull request #1676 from kleros/feat/rewards-and-execution-indicators
feat(web): ruling-and-rewards-indicators
2 parents cc4ccc5 + 4029771 commit dc91d63

File tree

5 files changed

+63
-5
lines changed

5 files changed

+63
-5
lines changed

web/src/hooks/queries/useVotingHistory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ const votingHistoryQuery = graphql(`
1212
dispute(id: $disputeID) {
1313
id
1414
createdAt
15+
ruled
1516
rounds {
1617
nbVotes
18+
jurorRewardsDispersed
1719
court {
1820
id
1921
name
@@ -25,6 +27,7 @@ const votingHistoryQuery = graphql(`
2527
}
2628
vote {
2729
... on ClassicVote {
30+
commited
2831
justification {
2932
choice
3033
reference
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
import styled from "styled-components";
3+
4+
import CheckCircle from "svgs/icons/check-circle-outline.svg";
5+
import Coins from "svgs/icons/pile-coins.svg";
6+
7+
import Label from "components/DisputeView/CardLabels/Label";
8+
9+
const Container = styled.div`
10+
display: flex;
11+
gap: 8px;
12+
flex-wrap: wrap;
13+
`;
14+
15+
interface IRulingAndRewardsIndicators {
16+
jurorRewardsDispersed: boolean;
17+
ruled: boolean;
18+
}
19+
20+
const RulingAndRewardsIndicators: React.FC<IRulingAndRewardsIndicators> = ({ jurorRewardsDispersed, ruled }) => (
21+
<Container>
22+
{ruled ? <Label icon={CheckCircle} text="Ruling executed" color="green" /> : null}
23+
{jurorRewardsDispersed ? <Label icon={Coins} text="Juror rewards distributed" color="green" /> : null}
24+
</Container>
25+
);
26+
27+
export default RulingAndRewardsIndicators;

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: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ import HowItWorks from "components/HowItWorks";
2222
import BinaryVoting from "components/Popup/MiniGuides/BinaryVoting";
2323

2424
import PendingVotesBox from "./PendingVotesBox";
25+
import RulingAndRewardsIndicators from "./RulingAndRewardsIndicators";
2526
import VotesAccordion from "./VotesDetails";
2627

2728
const Container = styled.div``;
2829

2930
const StyledTabs = styled(Tabs)`
3031
width: 100%;
3132
margin-bottom: 16px;
33+
margin-top: 48px;
3234
`;
3335

3436
const Header = styled.div`
@@ -69,6 +71,8 @@ const VotingHistory: React.FC<{ arbitrable?: `0x${string}`; isQuestion: boolean
6971
[votingHistory, currentTab]
7072
);
7173

74+
const jurorRewardsDispersed = useMemo(() => Boolean(rounds?.every((round) => round.jurorRewardsDispersed)), [rounds]);
75+
7276
return (
7377
<Container>
7478
<Header>
@@ -90,6 +94,10 @@ const VotingHistory: React.FC<{ arbitrable?: `0x${string}`; isQuestion: boolean
9094
)}
9195
</>
9296
)}
97+
<RulingAndRewardsIndicators
98+
ruled={Boolean(disputeData?.dispute?.ruled)}
99+
jurorRewardsDispersed={jurorRewardsDispersed}
100+
/>
93101
<StyledTabs
94102
currentValue={currentTab}
95103
items={rounds.map((_, i) => ({
@@ -108,6 +116,7 @@ const VotingHistory: React.FC<{ arbitrable?: `0x${string}`; isQuestion: boolean
108116
period={disputeData?.dispute?.period}
109117
answers={answers}
110118
isActiveRound={localRounds?.length - 1 === currentTab}
119+
hiddenVotes={Boolean(disputeData?.dispute?.court.hiddenVotes)}
111120
/>
112121
</>
113122
) : (

0 commit comments

Comments
 (0)