Skip to content

refactor(web): case details overview file too big #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
203 changes: 0 additions & 203 deletions web/src/pages/Cases/CaseDetails/Overview.tsx

This file was deleted.

66 changes: 66 additions & 0 deletions web/src/pages/Cases/CaseDetails/Overview/DisputeBasicInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import React from "react";
import ReactMarkdown from "react-markdown";
import styled from "styled-components";
import { StyledSkeleton } from "components/StyledSkeleton";
import { isUndefined } from "utils/index";

const QuestionAndDescription = styled.div`
display: flex;
flex-direction: column;
> * {
margin: 0px;
}
`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's take the margin out and make it more specific using styled components

Suggested change
const QuestionAndDescription = styled.div`
display: flex;
flex-direction: column;
> * {
margin: 0px;
}
`;
const QuestionAndDescription = styled.div`
display: flex;
flex-direction: column;
`;
const StyledReactMarkDown = styled(ReactMarkDown)`
margin: 0px;
`


const VotingOptions = styled(QuestionAndDescription)`
display: flex;
flex-direction: column;
gap: 8px;
`;

const Answers = styled.div`
display: flex;
flex-direction: column;

span {
margin: 0px;
display: flex;
gap: 8px;
}
`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here:

Suggested change
const Answers = styled.div`
display: flex;
flex-direction: column;
span {
margin: 0px;
display: flex;
gap: 8px;
}
`;
const AnswersContainer = styled.div`
display: flex;
flex-direction: column;
`;
const Answer = styled.span`
margin: 0px;
display: flex;
gap: 8px;
`


export const DisputeBasicInfo: React.FC<any> = ({ disputeTemplate }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's not use any and try to be more specific with typing

return (
<>
<h1>
{isUndefined(disputeTemplate) ? (
<StyledSkeleton />
) : (
disputeTemplate?.title ?? "The dispute's template is not correct please vote refuse to arbitrate"
)}
</h1>

<QuestionAndDescription>
<ReactMarkdown>{disputeTemplate?.question}</ReactMarkdown>
<ReactMarkdown>{disputeTemplate?.description}</ReactMarkdown>
</QuestionAndDescription>

{disputeTemplate?.frontendUrl && (
<a href={disputeTemplate?.frontendUrl} target="_blank" rel="noreferrer">
Go to arbitrable
</a>
)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have been trying to favor the following syntax on these situations (make sure to run it through the linter 😅 ):

Suggested change
{disputeTemplate?.frontendUrl && (
<a href={disputeTemplate?.frontendUrl} target="_blank" rel="noreferrer">
Go to arbitrable
</a>
)}
{isUndefined(disputeTemplate?.frontendUrl)
? null
: (
<a href={disputeTemplate?.frontendUrl} target="_blank" rel="noreferrer">
Go to arbitrable
</a>
)
}

<VotingOptions>
{disputeTemplate && <h3>Voting Options</h3>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as with the previous comment, let's try the other syntax

<Answers>
{disputeTemplate?.answers?.map((answer: { title: string; description: string }, i: number) => (
<span key={i}>
<small>Option {i + 1}:</small>
<label>{answer.title}</label>
</span>
))}
</Answers>
</VotingOptions>
</>
);
};
76 changes: 76 additions & 0 deletions web/src/pages/Cases/CaseDetails/Overview/Policies.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from "react";
import styled, { css } from "styled-components";
import { landscapeStyle } from "styles/landscapeStyle";
import { IPFS_GATEWAY } from "consts/index";
import PolicyIcon from "svgs/icons/policy.svg";

const ShadeArea = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
width: 100%;
padding: calc(16px + (20 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875)
calc(16px + (32 - 16) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
margin-top: 16px;
background-color: ${({ theme }) => theme.mediumBlue};
> p {
font-size: 14px;
margin-top: 0;
margin-bottom: 16px;
color: ${({ theme }) => theme.primaryBlue};
${landscapeStyle(
() => css`
margin-bottom: 0;
`
)};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move this out into its own styled component


${landscapeStyle(
() => css`
flex-direction: row;
justify-content: space-between;
`
)};
`;

const StyledA = styled.a`
display: flex;
align-items: center;
gap: 4px;
> svg {
width: 16px;
fill: ${({ theme }) => theme.primaryBlue};
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's take this out into its own styled component

`;

const LinkContainer = styled.div`
display: flex;
gap: calc(8px + (24 - 8) * (min(max(100vw, 375px), 1250px) - 375px) / 875);
`;

interface IPolicies {
disputePolicyURI?: string;
courtId?: number;
}

export const Policies: React.FC<IPolicies> = ({ disputePolicyURI, courtId }) => {
return (
<ShadeArea>
<p>Make sure you read and understand the Policies</p>
<LinkContainer>
{disputePolicyURI && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as with the previous cases, let's see how does it look using the ternary operator

<StyledA href={`${IPFS_GATEWAY}${disputePolicyURI}`} target="_blank" rel="noreferrer">
<PolicyIcon />
Dispute Policy
</StyledA>
)}
{courtId && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try the ternary operator here too

<StyledA href={`#/courts/${courtId}/purpose?section=description`}>
<PolicyIcon />
Court Policy
</StyledA>
)}
</LinkContainer>
</ShadeArea>
);
};
Loading