Skip to content

Commit 0795fbc

Browse files
authored
Merge pull request #1340 from kleros/refactor(web)/case-details-overview
refactor(web): case details overview file too big
2 parents 7483f1f + a0a583c commit 0795fbc

File tree

4 files changed

+257
-203
lines changed

4 files changed

+257
-203
lines changed

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

Lines changed: 0 additions & 203 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
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+
};
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import React from "react";
2+
import styled, { css } from "styled-components";
3+
import { landscapeStyle } from "styles/landscapeStyle";
4+
import { IPFS_GATEWAY } from "consts/index";
5+
import PolicyIcon from "svgs/icons/policy.svg";
6+
import { isUndefined } from "utils/index";
7+
8+
const ShadeArea = styled.div`
9+
display: flex;
10+
flex-direction: column;
11+
justify-content: center;
12+
width: 100%;
13+
padding: calc(16px + (20 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875)
14+
calc(16px + (32 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
15+
margin-top: 16px;
16+
background-color: ${({ theme }) => theme.mediumBlue};
17+
18+
${landscapeStyle(
19+
() => css`
20+
flex-direction: row;
21+
justify-content: space-between;
22+
`
23+
)};
24+
`;
25+
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+
38+
const StyledA = styled.a`
39+
display: flex;
40+
align-items: center;
41+
gap: 4px;
42+
`;
43+
44+
const StyledPolicyIcon = styled(PolicyIcon)`
45+
width: 16px;
46+
fill: ${({ theme }) => theme.primaryBlue};
47+
`;
48+
49+
const LinkContainer = styled.div`
50+
display: flex;
51+
gap: calc(8px + (24 - 8) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
52+
`;
53+
54+
interface IPolicies {
55+
disputePolicyURI?: string;
56+
courtId?: string;
57+
}
58+
59+
export const Policies: React.FC<IPolicies> = ({ disputePolicyURI, courtId }) => {
60+
return (
61+
<ShadeArea>
62+
<StyledP>Make sure you read and understand the Policies</StyledP>
63+
<LinkContainer>
64+
{isUndefined(disputePolicyURI) ? null : (
65+
<StyledA href={`${IPFS_GATEWAY}${disputePolicyURI}`} target="_blank" rel="noreferrer">
66+
<StyledPolicyIcon />
67+
Dispute Policy
68+
</StyledA>
69+
)}
70+
{isUndefined(courtId) ? null : (
71+
<StyledA href={`#/courts/${courtId}/purpose?section=description`}>
72+
<StyledPolicyIcon />
73+
Court Policy
74+
</StyledA>
75+
)}
76+
</LinkContainer>
77+
</ShadeArea>
78+
);
79+
};

0 commit comments

Comments
 (0)