|
1 |
| -import React from "react"; |
| 1 | +import React, { useMemo } from "react"; |
2 | 2 | import styled from "styled-components";
|
3 | 3 |
|
4 | 4 | import { DisputeDetails } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsTypes";
|
| 5 | +import { useAccount } from "wagmi"; |
5 | 6 |
|
6 | 7 | import { INVALID_DISPUTE_DATA_ERROR, RPC_ERROR } from "consts/index";
|
7 | 8 | import { Answer as IAnswer } from "context/NewDisputeContext";
|
8 | 9 | import { isUndefined } from "utils/index";
|
9 | 10 |
|
10 | 11 | import { responsiveSize } from "styles/responsiveSize";
|
11 | 12 |
|
| 13 | +import { DisputeDetailsQuery, VotingHistoryQuery } from "src/graphql/graphql"; |
| 14 | + |
12 | 15 | import ReactMarkdown from "components/ReactMarkdown";
|
13 | 16 | import { StyledSkeleton } from "components/StyledSkeleton";
|
14 | 17 |
|
15 | 18 | import { Divider } from "../Divider";
|
16 | 19 | import { ExternalLink } from "../ExternalLink";
|
17 | 20 |
|
18 | 21 | import AliasDisplay from "./Alias";
|
| 22 | +import RulingAndRewardsIndicators from "../Verdict/RulingAndRewardsIndicators"; |
| 23 | +import CardLabel from "../DisputeView/CardLabels"; |
19 | 24 |
|
20 | 25 | const StyledH1 = styled.h1`
|
21 | 26 | margin: 0;
|
22 | 27 | word-wrap: break-word;
|
23 |
| - font-size: ${responsiveSize(18, 24)}; |
| 28 | + font-size: ${responsiveSize(20, 26)}; |
24 | 29 | line-height: 24px;
|
25 | 30 | `;
|
26 | 31 |
|
| 32 | +const TitleSection = styled.div` |
| 33 | + display: flex; |
| 34 | + flex-direction: column; |
| 35 | + gap: 12px; |
| 36 | +`; |
| 37 | + |
27 | 38 | const ReactMarkdownWrapper = styled.div`
|
28 | 39 | & p:first-of-type {
|
29 | 40 | margin: 0;
|
@@ -66,19 +77,59 @@ const AliasesContainer = styled.div`
|
66 | 77 | gap: ${responsiveSize(8, 20)};
|
67 | 78 | `;
|
68 | 79 |
|
| 80 | +const RulingAndRewardsAndLabels = styled.div` |
| 81 | + display: flex; |
| 82 | + flex-direction: row; |
| 83 | + flex-wrap: wrap; |
| 84 | + gap: 8px; |
| 85 | +`; |
| 86 | + |
69 | 87 | interface IDisputeContext {
|
70 | 88 | disputeDetails?: DisputeDetails;
|
71 | 89 | isRpcError?: boolean;
|
| 90 | + dispute?: DisputeDetailsQuery | undefined; |
| 91 | + |
| 92 | + disputeId?: string; |
| 93 | + votingHistory?: VotingHistoryQuery | undefined; |
72 | 94 | }
|
73 | 95 |
|
74 |
| -export const DisputeContext: React.FC<IDisputeContext> = ({ disputeDetails, isRpcError = false }) => { |
| 96 | +export const DisputeContext: React.FC<IDisputeContext> = ({ |
| 97 | + disputeDetails, |
| 98 | + isRpcError = false, |
| 99 | + dispute, |
| 100 | + disputeId, |
| 101 | + votingHistory, |
| 102 | +}) => { |
| 103 | + const { isDisconnected } = useAccount(); |
75 | 104 | const errMsg = isRpcError ? RPC_ERROR : INVALID_DISPUTE_DATA_ERROR;
|
| 105 | + const rounds = votingHistory?.dispute?.rounds; |
| 106 | + const jurorRewardsDispersed = useMemo(() => Boolean(rounds?.every((round) => round.jurorRewardsDispersed)), [rounds]); |
| 107 | + console.log({ jurorRewardsDispersed }, disputeDetails); |
76 | 108 |
|
77 | 109 | return (
|
78 | 110 | <>
|
79 |
| - <StyledH1 dir="auto"> |
80 |
| - {isUndefined(disputeDetails) ? <StyledSkeleton /> : (disputeDetails?.title ?? errMsg)} |
81 |
| - </StyledH1> |
| 111 | + <TitleSection> |
| 112 | + <StyledH1 dir="auto"> |
| 113 | + {isUndefined(disputeDetails) ? <StyledSkeleton /> : (disputeDetails?.title ?? errMsg)} |
| 114 | + </StyledH1> |
| 115 | + {!isUndefined(disputeDetails) && |
| 116 | + !isUndefined(dispute) && |
| 117 | + !isUndefined(disputeId) && |
| 118 | + !isUndefined(votingHistory) ? ( |
| 119 | + <RulingAndRewardsAndLabels> |
| 120 | + {!isUndefined(Boolean(dispute?.dispute?.ruled)) || jurorRewardsDispersed ? ( |
| 121 | + <RulingAndRewardsIndicators |
| 122 | + ruled={Boolean(dispute?.dispute?.ruled)} |
| 123 | + jurorRewardsDispersed={jurorRewardsDispersed} |
| 124 | + /> |
| 125 | + ) : null} |
| 126 | + {!isDisconnected ? ( |
| 127 | + <CardLabel {...{ disputeId }} round={rounds?.length - 1} isList={false} isOverview={true} /> |
| 128 | + ) : null} |
| 129 | + </RulingAndRewardsAndLabels> |
| 130 | + ) : null} |
| 131 | + <Divider /> |
| 132 | + </TitleSection> |
82 | 133 | {disputeDetails?.question?.trim() || disputeDetails?.description?.trim() ? (
|
83 | 134 | <div>
|
84 | 135 | {disputeDetails?.question?.trim() ? (
|
|
0 commit comments