Skip to content

Commit

Permalink
Merge pull request #1485 from kleros/fix(web)/fix-case-ongoing-details
Browse files Browse the repository at this point in the history
Fix(web)/fix case ongoing details
  • Loading branch information
alcercu authored Feb 6, 2024
2 parents b2eccc6 + 5db5e17 commit ad24ce1
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 23 deletions.
26 changes: 26 additions & 0 deletions web/src/components/Verdict/Answer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";
import { Answer } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsTypes";
import styled from "styled-components";

const AnswerTitle = styled.h3`
margin: 0;
`;
interface IAnswer {
answer?: Answer;
currentRuling: number;
}
const AnswerDisplay: React.FC<IAnswer> = ({ answer, currentRuling }) => {
return (
<>
{answer ? (
<div>
<AnswerTitle>{answer.title}</AnswerTitle>
<small>{answer.description}</small>
</div>
) : (
<>{currentRuling !== 0 ? <h3>Answer 0x{currentRuling}</h3> : <h3>Refuse to Arbitrate</h3>}</>
)}
</>
);
};
export default AnswerDisplay;
34 changes: 17 additions & 17 deletions web/src/components/Verdict/FinalDecision.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { responsiveSize } from "styles/responsiveSize";
import { useVotingContext } from "hooks/useVotingContext";
import Skeleton from "react-loading-skeleton";
import { useAccount } from "wagmi";
import AnswerDisplay from "./Answer";
import { useVotingHistory } from "hooks/queries/useVotingHistory";
import { getLocalRounds } from "utils/getLocalRounds";
import { Periods } from "consts/periods";

const Container = styled.div`
width: 100%;
Expand Down Expand Up @@ -42,10 +46,6 @@ const StyledButton = styled(LightButton)`
padding-top: 0px;
`;

const AnswerTitle = styled.h3`
margin: 0;
`;

const Divider = styled.hr`
display: flex;
border: none;
Expand All @@ -64,7 +64,10 @@ const FinalDecision: React.FC<IFinalDecision> = ({ arbitrable }) => {
const { data: populatedDisputeData } = usePopulatedDisputeData(id, arbitrable);
const { data: disputeDetails } = useDisputeDetailsQuery(id);
const { wasDrawn, hasVoted, isLoading, isCommitPeriod, isVotingPeriod, commited, isHiddenVotes } = useVotingContext();
const { data: votingHistory } = useVotingHistory(id);
const localRounds = getLocalRounds(votingHistory?.dispute?.disputeKitDispute);
const ruled = disputeDetails?.dispute?.ruled ?? false;
const periodIndex = Periods[disputeDetails?.dispute?.period ?? "evidence"];
const navigate = useNavigate();
const { data: currentRulingArray } = useKlerosCoreCurrentRuling({ args: [BigInt(id ?? 0)], watch: true });
const currentRuling = Number(currentRulingArray?.[0]);
Expand All @@ -81,21 +84,18 @@ const FinalDecision: React.FC<IFinalDecision> = ({ arbitrable }) => {
<Container>
<VerdictBanner ruled={ruled} />

<JuryContainer>
{ruled ? (
{ruled && (
<JuryContainer>
<JuryDecisionTag>The jury decided in favor of:</JuryDecisionTag>
) : (
<AnswerDisplay {...{ answer, currentRuling }} />
</JuryContainer>
)}
{!ruled && periodIndex > 1 && localRounds?.at(localRounds.length - 1)?.totalVoted > 0 && (
<JuryContainer>
<JuryDecisionTag>This option is winning:</JuryDecisionTag>
)}
{answer ? (
<div>
<AnswerTitle>{answer.title}</AnswerTitle>
<small>{answer.description}</small>
</div>
) : (
<>{currentRuling !== 0 ? <h3>Answer 0x{currentRuling}</h3> : <h3>Refuse to Arbitrate</h3>}</>
)}
</JuryContainer>
<AnswerDisplay {...{ answer, currentRuling }} />
</JuryContainer>
)}
<Divider />
{isLoading && !isDisconnected ? (
<Skeleton width={250} height={20} />
Expand Down
4 changes: 2 additions & 2 deletions web/src/pages/Cases/CaseDetails/Voting/Classic/Vote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const Vote: React.FC<IVote> = ({ arbitrable, voteIDs, setIsOpen }) => {
],
});
if (walletClient) {
await wrapWithToast(async () => await walletClient.writeContract(request), publicClient).then(() => {
setIsOpen(true);
await wrapWithToast(async () => await walletClient.writeContract(request), publicClient).then(({ status }) => {
setIsOpen(status);
});
}
},
Expand Down
12 changes: 8 additions & 4 deletions web/src/pages/Cases/CaseDetails/Voting/VotingHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ const VotingHistory: React.FC<{ arbitrable?: `0x${string}`; isQuestion: boolean
</Header>
{rounds && localRounds && disputeDetails ? (
<>
{isQuestion && disputeDetails.question ? (
<ReactMarkdown>{disputeDetails.question}</ReactMarkdown>
) : (
<ReactMarkdown>{isError ? RPC_ERROR : INVALID_DISPUTE_DATA_ERROR}</ReactMarkdown>
{isQuestion && (
<>
{disputeDetails.question ? (
<ReactMarkdown>{disputeDetails.question}</ReactMarkdown>
) : (
<ReactMarkdown>{isError ? RPC_ERROR : INVALID_DISPUTE_DATA_ERROR}</ReactMarkdown>
)}
</>
)}
<StyledTabs
currentValue={currentTab}
Expand Down

0 comments on commit ad24ce1

Please sign in to comment.