Skip to content

Commit 78508f5

Browse files
committed
feat: add card labels to the overview
1 parent 47aaca4 commit 78508f5

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

web/src/components/DisputePreview/DisputeContext.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React, { useMemo } from "react";
22
import styled from "styled-components";
33

44
import { DisputeDetails } from "@kleros/kleros-sdk/src/dataMappings/utils/disputeDetailsTypes";
5+
import { useParams } from "react-router-dom";
6+
import { useAccount } from "wagmi";
57

68
import { INVALID_DISPUTE_DATA_ERROR, RPC_ERROR } from "consts/index";
79
import { Answer as IAnswer } from "context/NewDisputeContext";
@@ -19,6 +21,7 @@ import { ExternalLink } from "../ExternalLink";
1921

2022
import AliasDisplay from "./Alias";
2123
import RulingAndRewardsIndicators from "../Verdict/RulingAndRewardsIndicators";
24+
import CardLabel from "../DisputeView/CardLabels";
2225

2326
const StyledH1 = styled.h1`
2427
margin: 0;
@@ -75,6 +78,13 @@ const AliasesContainer = styled.div`
7578
gap: ${responsiveSize(8, 20)};
7679
`;
7780

81+
const RulingAndRewardsAndLabels = styled.div`
82+
display: flex;
83+
flex-direction: row;
84+
flex-wrap: wrap;
85+
gap: 8px;
86+
`;
87+
7888
interface IDisputeContext {
7989
disputeDetails?: DisputeDetails;
8090
dispute: DisputeDetailsQuery | undefined;
@@ -88,6 +98,8 @@ export const DisputeContext: React.FC<IDisputeContext> = ({
8898
isRpcError = false,
8999
votingHistory,
90100
}) => {
101+
const { id } = useParams();
102+
const { isDisconnected } = useAccount();
91103
const errMsg = isRpcError ? RPC_ERROR : INVALID_DISPUTE_DATA_ERROR;
92104
const rounds = votingHistory?.dispute?.rounds;
93105
const jurorRewardsDispersed = useMemo(() => Boolean(rounds?.every((round) => round.jurorRewardsDispersed)), [rounds]);
@@ -99,12 +111,17 @@ export const DisputeContext: React.FC<IDisputeContext> = ({
99111
<StyledH1 dir="auto">
100112
{isUndefined(disputeDetails) ? <StyledSkeleton /> : (disputeDetails?.title ?? errMsg)}
101113
</StyledH1>
102-
{!isUndefined(Boolean(dispute?.dispute?.ruled)) || jurorRewardsDispersed ? (
103-
<RulingAndRewardsIndicators
104-
ruled={Boolean(dispute?.dispute?.ruled)}
105-
jurorRewardsDispersed={jurorRewardsDispersed}
106-
/>
107-
) : null}
114+
<RulingAndRewardsAndLabels>
115+
{!isUndefined(Boolean(dispute?.dispute?.ruled)) || jurorRewardsDispersed ? (
116+
<RulingAndRewardsIndicators
117+
ruled={Boolean(dispute?.dispute?.ruled)}
118+
jurorRewardsDispersed={jurorRewardsDispersed}
119+
/>
120+
) : null}
121+
{!isDisconnected ? (
122+
<CardLabel disputeId={id} round={rounds?.length - 1} isList={false} isOverview={true} />
123+
) : null}
124+
</RulingAndRewardsAndLabels>
108125
<Divider />
109126
</TitleSection>
110127
{disputeDetails?.question?.trim() || disputeDetails?.description?.trim() ? (

web/src/components/DisputeView/CardLabels/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@ import { ClassicContribution } from "src/graphql/graphql";
2222
import Label, { IColors } from "./Label";
2323
import RewardsAndFundLabel from "./RewardsAndFundLabel";
2424

25-
const Container = styled.div<{ isList: boolean }>`
25+
const Container = styled.div<{ isList: boolean; isOverview: boolean }>`
2626
display: flex;
2727
gap: 8px;
2828
flex-direction: column;
2929
align-items: end;
30+
3031
${({ isList }) =>
3132
!isList &&
3233
css`
@@ -36,7 +37,16 @@ const Container = styled.div<{ isList: boolean }>`
3637
flex-direction: row;
3738
align-items: center;
3839
`}
40+
41+
${({ isOverview }) =>
42+
isOverview &&
43+
css`
44+
margin-top: 0;
45+
flex-direction: row;
46+
width: auto;
47+
`}
3948
`;
49+
4050
const RewardsContainer = styled.div`
4151
display: flex;
4252
gap: 4px 8px;
@@ -47,6 +57,7 @@ interface ICardLabels {
4757
disputeId: string;
4858
round: number;
4959
isList: boolean;
60+
isOverview?: boolean;
5061
}
5162

5263
const LabelArgs: Record<string, { text: string; icon: React.FC<React.SVGAttributes<SVGElement>>; color: IColors }> = {
@@ -73,7 +84,7 @@ const getFundingRewards = (contributions: ClassicContribution[], closed: boolean
7384
return Number(formatUnits(BigInt(contribution), 18));
7485
};
7586

76-
const CardLabel: React.FC<ICardLabels> = ({ disputeId, round, isList }) => {
87+
const CardLabel: React.FC<ICardLabels> = ({ disputeId, round, isList, isOverview = false }) => {
7788
const { address } = useAccount();
7889
const { data: labelInfo, isLoading } = useLabelInfoQuery(address?.toLowerCase(), disputeId);
7990
const localRounds = getLocalRounds(labelInfo?.dispute?.disputeKitDispute);
@@ -139,7 +150,7 @@ const CardLabel: React.FC<ICardLabels> = ({ disputeId, round, isList }) => {
139150
}, [contributionRewards, shifts]);
140151

141152
return (
142-
<Container {...{ isList }}>
153+
<Container {...{ isList, isOverview }}>
143154
{isLoading ? (
144155
<Skeleton width={130} height={14} />
145156
) : (

0 commit comments

Comments
 (0)