Skip to content

Commit ad24ce1

Browse files
authored
Merge pull request #1485 from kleros/fix(web)/fix-case-ongoing-details
Fix(web)/fix case ongoing details
2 parents b2eccc6 + 5db5e17 commit ad24ce1

File tree

4 files changed

+53
-23
lines changed

4 files changed

+53
-23
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from "react";
2+
import { Answer } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsTypes";
3+
import styled from "styled-components";
4+
5+
const AnswerTitle = styled.h3`
6+
margin: 0;
7+
`;
8+
interface IAnswer {
9+
answer?: Answer;
10+
currentRuling: number;
11+
}
12+
const AnswerDisplay: React.FC<IAnswer> = ({ answer, currentRuling }) => {
13+
return (
14+
<>
15+
{answer ? (
16+
<div>
17+
<AnswerTitle>{answer.title}</AnswerTitle>
18+
<small>{answer.description}</small>
19+
</div>
20+
) : (
21+
<>{currentRuling !== 0 ? <h3>Answer 0x{currentRuling}</h3> : <h3>Refuse to Arbitrate</h3>}</>
22+
)}
23+
</>
24+
);
25+
};
26+
export default AnswerDisplay;

web/src/components/Verdict/FinalDecision.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import { responsiveSize } from "styles/responsiveSize";
1111
import { useVotingContext } from "hooks/useVotingContext";
1212
import Skeleton from "react-loading-skeleton";
1313
import { useAccount } from "wagmi";
14+
import AnswerDisplay from "./Answer";
15+
import { useVotingHistory } from "hooks/queries/useVotingHistory";
16+
import { getLocalRounds } from "utils/getLocalRounds";
17+
import { Periods } from "consts/periods";
1418

1519
const Container = styled.div`
1620
width: 100%;
@@ -42,10 +46,6 @@ const StyledButton = styled(LightButton)`
4246
padding-top: 0px;
4347
`;
4448

45-
const AnswerTitle = styled.h3`
46-
margin: 0;
47-
`;
48-
4949
const Divider = styled.hr`
5050
display: flex;
5151
border: none;
@@ -64,7 +64,10 @@ const FinalDecision: React.FC<IFinalDecision> = ({ arbitrable }) => {
6464
const { data: populatedDisputeData } = usePopulatedDisputeData(id, arbitrable);
6565
const { data: disputeDetails } = useDisputeDetailsQuery(id);
6666
const { wasDrawn, hasVoted, isLoading, isCommitPeriod, isVotingPeriod, commited, isHiddenVotes } = useVotingContext();
67+
const { data: votingHistory } = useVotingHistory(id);
68+
const localRounds = getLocalRounds(votingHistory?.dispute?.disputeKitDispute);
6769
const ruled = disputeDetails?.dispute?.ruled ?? false;
70+
const periodIndex = Periods[disputeDetails?.dispute?.period ?? "evidence"];
6871
const navigate = useNavigate();
6972
const { data: currentRulingArray } = useKlerosCoreCurrentRuling({ args: [BigInt(id ?? 0)], watch: true });
7073
const currentRuling = Number(currentRulingArray?.[0]);
@@ -81,21 +84,18 @@ const FinalDecision: React.FC<IFinalDecision> = ({ arbitrable }) => {
8184
<Container>
8285
<VerdictBanner ruled={ruled} />
8386

84-
<JuryContainer>
85-
{ruled ? (
87+
{ruled && (
88+
<JuryContainer>
8689
<JuryDecisionTag>The jury decided in favor of:</JuryDecisionTag>
87-
) : (
90+
<AnswerDisplay {...{ answer, currentRuling }} />
91+
</JuryContainer>
92+
)}
93+
{!ruled && periodIndex > 1 && localRounds?.at(localRounds.length - 1)?.totalVoted > 0 && (
94+
<JuryContainer>
8895
<JuryDecisionTag>This option is winning:</JuryDecisionTag>
89-
)}
90-
{answer ? (
91-
<div>
92-
<AnswerTitle>{answer.title}</AnswerTitle>
93-
<small>{answer.description}</small>
94-
</div>
95-
) : (
96-
<>{currentRuling !== 0 ? <h3>Answer 0x{currentRuling}</h3> : <h3>Refuse to Arbitrate</h3>}</>
97-
)}
98-
</JuryContainer>
96+
<AnswerDisplay {...{ answer, currentRuling }} />
97+
</JuryContainer>
98+
)}
9999
<Divider />
100100
{isLoading && !isDisconnected ? (
101101
<Skeleton width={250} height={20} />

web/src/pages/Cases/CaseDetails/Voting/Classic/Vote.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ const Vote: React.FC<IVote> = ({ arbitrable, voteIDs, setIsOpen }) => {
4040
],
4141
});
4242
if (walletClient) {
43-
await wrapWithToast(async () => await walletClient.writeContract(request), publicClient).then(() => {
44-
setIsOpen(true);
43+
await wrapWithToast(async () => await walletClient.writeContract(request), publicClient).then(({ status }) => {
44+
setIsOpen(status);
4545
});
4646
}
4747
},

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,14 @@ const VotingHistory: React.FC<{ arbitrable?: `0x${string}`; isQuestion: boolean
6969
</Header>
7070
{rounds && localRounds && disputeDetails ? (
7171
<>
72-
{isQuestion && disputeDetails.question ? (
73-
<ReactMarkdown>{disputeDetails.question}</ReactMarkdown>
74-
) : (
75-
<ReactMarkdown>{isError ? RPC_ERROR : INVALID_DISPUTE_DATA_ERROR}</ReactMarkdown>
72+
{isQuestion && (
73+
<>
74+
{disputeDetails.question ? (
75+
<ReactMarkdown>{disputeDetails.question}</ReactMarkdown>
76+
) : (
77+
<ReactMarkdown>{isError ? RPC_ERROR : INVALID_DISPUTE_DATA_ERROR}</ReactMarkdown>
78+
)}
79+
</>
7680
)}
7781
<StyledTabs
7882
currentValue={currentTab}

0 commit comments

Comments
 (0)