Skip to content

Commit a0a583c

Browse files
committed
refactor(web): resolve suggestions
1 parent 2d6de9d commit a0a583c

File tree

4 files changed

+128
-100
lines changed

4 files changed

+128
-100
lines changed

web/src/pages/Cases/CaseDetails/Overview/DisputeBasicInfo.tsx

-66
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import React from "react";
2+
import ReactMarkdown from "components/ReactMarkdown";
3+
import styled from "styled-components";
4+
import { StyledSkeleton } from "components/StyledSkeleton";
5+
import { isUndefined } from "utils/index";
6+
7+
const StyledH1 = styled.h1`
8+
margin: 0;
9+
`;
10+
11+
const QuestionAndDescription = styled.div`
12+
display: flex;
13+
flex-direction: column;
14+
`;
15+
16+
const StyledReactMarkDown = styled(ReactMarkdown)`
17+
margin: 0px;
18+
`;
19+
20+
const VotingOptions = styled(QuestionAndDescription)`
21+
display: flex;
22+
flex-direction: column;
23+
gap: 8px;
24+
`;
25+
26+
const AnswersContainer = styled.div`
27+
display: flex;
28+
flex-direction: column;
29+
`;
30+
31+
const Answer = styled.div`
32+
margin: 0px;
33+
display: flex;
34+
gap: 8px;
35+
`;
36+
37+
interface IAnswer {
38+
id?: string;
39+
title: string;
40+
description?: string;
41+
reserved?: boolean;
42+
}
43+
44+
interface IDisputeTemplate {
45+
answers: IAnswer[];
46+
arbitrableAddress: string;
47+
arbitrableChainID: string;
48+
arbitratorAddress: string;
49+
arbitratorChainID: string;
50+
category?: string;
51+
description: string;
52+
frontendUrl?: string;
53+
lang?: string;
54+
policyURI?: string;
55+
question: string;
56+
specification?: string;
57+
title: string;
58+
}
59+
60+
interface IDisputeContext {
61+
disputeTemplate: IDisputeTemplate;
62+
}
63+
64+
export const DisputeContext: React.FC<IDisputeContext> = ({ disputeTemplate }) => {
65+
return (
66+
<>
67+
<StyledH1>
68+
{isUndefined(disputeTemplate) ? (
69+
<StyledSkeleton />
70+
) : (
71+
disputeTemplate?.title ?? "The dispute's template is not correct please vote refuse to arbitrate"
72+
)}
73+
</StyledH1>
74+
75+
<QuestionAndDescription>
76+
<StyledReactMarkDown>{disputeTemplate?.question}</StyledReactMarkDown>
77+
<StyledReactMarkDown>{disputeTemplate?.description}</StyledReactMarkDown>
78+
</QuestionAndDescription>
79+
80+
{isUndefined(disputeTemplate?.frontendUrl) ? null : (
81+
<a href={disputeTemplate?.frontendUrl} target="_blank" rel="noreferrer">
82+
Go to arbitrable
83+
</a>
84+
)}
85+
<VotingOptions>
86+
{isUndefined(disputeTemplate) ? null : <h3>Voting Options</h3>}
87+
<AnswersContainer>
88+
{disputeTemplate?.answers?.map((answer: IAnswer, i: number) => (
89+
<Answer key={i}>
90+
<small>Option {i + 1}:</small>
91+
<label>{answer.title}</label>
92+
</Answer>
93+
))}
94+
</AnswersContainer>
95+
</VotingOptions>
96+
</>
97+
);
98+
};

web/src/pages/Cases/CaseDetails/Overview/Policies.tsx

+24-21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled, { css } from "styled-components";
33
import { landscapeStyle } from "styles/landscapeStyle";
44
import { IPFS_GATEWAY } from "consts/index";
55
import PolicyIcon from "svgs/icons/policy.svg";
6+
import { isUndefined } from "utils/index";
67

78
const ShadeArea = styled.div`
89
display: flex;
@@ -13,17 +14,6 @@ const ShadeArea = styled.div`
1314
calc(16px + (32 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
1415
margin-top: 16px;
1516
background-color: ${({ theme }) => theme.mediumBlue};
16-
> p {
17-
font-size: 14px;
18-
margin-top: 0;
19-
margin-bottom: 16px;
20-
color: ${({ theme }) => theme.primaryBlue};
21-
${landscapeStyle(
22-
() => css`
23-
margin-bottom: 0;
24-
`
25-
)};
26-
}
2717
2818
${landscapeStyle(
2919
() => css`
@@ -33,14 +23,27 @@ const ShadeArea = styled.div`
3323
)};
3424
`;
3525

26+
const StyledP = styled.p`
27+
font-size: 14px;
28+
margin-top: 0;
29+
margin-bottom: 16px;
30+
color: ${({ theme }) => theme.primaryBlue};
31+
${landscapeStyle(
32+
() => css`
33+
margin-bottom: 0;
34+
`
35+
)};
36+
`;
37+
3638
const StyledA = styled.a`
3739
display: flex;
3840
align-items: center;
3941
gap: 4px;
40-
> svg {
41-
width: 16px;
42-
fill: ${({ theme }) => theme.primaryBlue};
43-
}
42+
`;
43+
44+
const StyledPolicyIcon = styled(PolicyIcon)`
45+
width: 16px;
46+
fill: ${({ theme }) => theme.primaryBlue};
4447
`;
4548

4649
const LinkContainer = styled.div`
@@ -50,23 +53,23 @@ const LinkContainer = styled.div`
5053

5154
interface IPolicies {
5255
disputePolicyURI?: string;
53-
courtId?: number;
56+
courtId?: string;
5457
}
5558

5659
export const Policies: React.FC<IPolicies> = ({ disputePolicyURI, courtId }) => {
5760
return (
5861
<ShadeArea>
59-
<p>Make sure you read and understand the Policies</p>
62+
<StyledP>Make sure you read and understand the Policies</StyledP>
6063
<LinkContainer>
61-
{disputePolicyURI && (
64+
{isUndefined(disputePolicyURI) ? null : (
6265
<StyledA href={`${IPFS_GATEWAY}${disputePolicyURI}`} target="_blank" rel="noreferrer">
63-
<PolicyIcon />
66+
<StyledPolicyIcon />
6467
Dispute Policy
6568
</StyledA>
6669
)}
67-
{courtId && (
70+
{isUndefined(courtId) ? null : (
6871
<StyledA href={`#/courts/${courtId}/purpose?section=description`}>
69-
<PolicyIcon />
72+
<StyledPolicyIcon />
7073
Court Policy
7174
</StyledA>
7275
)}

web/src/pages/Cases/CaseDetails/Overview/index.tsx

+6-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useMemo } from "react";
22
import styled from "styled-components";
33
import { useParams } from "react-router-dom";
44
import { formatEther } from "viem";
@@ -11,7 +11,7 @@ import DisputeInfo from "components/DisputeCard/DisputeInfo";
1111
import Verdict from "components/Verdict/index";
1212
import { useVotingHistory } from "hooks/queries/useVotingHistory";
1313
import { getLocalRounds } from "utils/getLocalRounds";
14-
import { DisputeBasicInfo } from "./DisputeBasicInfo";
14+
import { DisputeContext } from "./DisputeContext";
1515
import { Policies } from "./Policies";
1616

1717
const Container = styled.div`
@@ -21,17 +21,10 @@ const Container = styled.div`
2121
flex-direction: column;
2222
gap: calc(16px + (32 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
2323
padding: calc(16px + (32 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
24-
25-
> h1 {
26-
margin: 0;
27-
}
28-
29-
> hr {
30-
width: 100%;
31-
}
3224
`;
3325

3426
const Divider = styled.hr`
27+
width: 100%;
3528
display: flex;
3629
border: none;
3730
height: 1px;
@@ -54,13 +47,13 @@ const Overview: React.FC<IOverview> = ({ arbitrable, courtID, currentPeriodIndex
5447
const localRounds = getLocalRounds(votingHistory?.dispute?.disputeKitDispute);
5548
const courtName = courtPolicy?.name;
5649
const court = disputeDetails?.dispute?.court;
57-
const rewards = court ? `≥ ${formatEther(court.feeForJuror)} ETH` : undefined;
50+
const rewards = useMemo(() => (court ? `≥ ${formatEther(court.feeForJuror)} ETH` : undefined), [court]);
5851
const category = disputeTemplate?.category ?? undefined;
5952

6053
return (
6154
<>
6255
<Container>
63-
<DisputeBasicInfo disputeTemplate={disputeTemplate} />
56+
<DisputeContext disputeTemplate={disputeTemplate} />
6457
<Divider />
6558

6659
{currentPeriodIndex !== Periods.evidence && (
@@ -79,7 +72,7 @@ const Overview: React.FC<IOverview> = ({ arbitrable, courtID, currentPeriodIndex
7972
{...{ rewards, category }}
8073
/>
8174
</Container>
82-
<Policies disputePolicyURI={disputeTemplate?.policyURI} courtId={courtPolicy && court?.id} />
75+
<Policies disputePolicyURI={disputeTemplate?.policyURI} courtId={courtID} />
8376
</>
8477
);
8578
};

0 commit comments

Comments
 (0)