Skip to content

Commit fd6a186

Browse files
committed
feat: add policy file to the file viewer
1 parent 0dded80 commit fd6a186

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

web/src/components/DisputePreview/Policies.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from "react";
22
import styled, { css } from "styled-components";
33

4+
import { Link } from "react-router-dom";
5+
46
import PaperclipIcon from "svgs/icons/paperclip.svg";
57
import PolicyIcon from "svgs/icons/policy.svg";
68

@@ -59,6 +61,12 @@ const LinkContainer = styled.div`
5961
display: flex;
6062
gap: ${responsiveSize(16, 24)};
6163
flex-wrap: wrap;
64+
align-items: center;
65+
`;
66+
67+
const StyledLink = styled(Link)`
68+
display: flex;
69+
gap: 4px;
6270
`;
6371

6472
type Attachment = {
@@ -83,10 +91,10 @@ export const Policies: React.FC<IPolicies> = ({ disputePolicyURI, courtId, attac
8391
</StyledA>
8492
) : null}
8593
{isUndefined(disputePolicyURI) ? null : (
86-
<StyledA href={getIpfsUrl(disputePolicyURI)} target="_blank" rel="noreferrer">
94+
<StyledLink to={`policy/attachment/?url=${getIpfsUrl(disputePolicyURI)}`}>
8795
<StyledPolicyIcon />
8896
Dispute Policy
89-
</StyledA>
97+
</StyledLink>
9098
)}
9199
{isUndefined(courtId) ? null : (
92100
<StyledA href={`#/courts/${courtId}/purpose?section=description`}>

web/src/pages/Cases/AttachmentDisplay/Header.tsx

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from "react";
22
import styled from "styled-components";
33

4-
import { useNavigate, useParams } from "react-router-dom";
4+
import { useNavigate, useLocation, useParams } from "react-router-dom";
55

66
import { Button } from "@kleros/ui-components-library";
77

@@ -57,16 +57,23 @@ const StyledButton = styled(Button)`
5757
`;
5858

5959
const Header: React.FC = () => {
60-
const { id } = useParams();
6160
const navigate = useNavigate();
61+
const { id } = useParams();
62+
const location = useLocation();
63+
64+
const handleReturn = () => {
65+
navigate(-1);
66+
};
67+
68+
const title = location.pathname.includes("policy") ? `Policy File - Case #${id}` : "Attachment File";
6269

6370
return (
6471
<Container>
6572
<TitleContainer>
6673
<StyledPaperClip />
67-
<Title>Attachment File</Title>{" "}
74+
<Title>{title}</Title>
6875
</TitleContainer>
69-
<StyledButton text="Return" Icon={Arrow} onClick={() => navigate(`/cases/${id}/evidence`)} />
76+
<StyledButton text="Return" Icon={Arrow} onClick={handleReturn} />
7077
</Container>
7178
);
7279
};

web/src/pages/Cases/AttachmentDisplay/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const StyledNewTabIcon = styled(NewTabIcon)`
3737
}
3838
`;
3939

40-
const EvidenceAttachmentDisplay: React.FC = () => {
40+
const AttachmentDisplay: React.FC = () => {
4141
const [searchParams] = useSearchParams();
4242

4343
const url = searchParams.get("url");
@@ -64,4 +64,4 @@ const EvidenceAttachmentDisplay: React.FC = () => {
6464
);
6565
};
6666

67-
export default EvidenceAttachmentDisplay;
67+
export default AttachmentDisplay;

web/src/pages/Cases/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Routes, Route } from "react-router-dom";
55

66
import { responsiveSize } from "styles/responsiveSize";
77

8-
import EvidenceAttachmentDisplay from "./AttachmentDisplay";
8+
import AttachmentDisplay from "./AttachmentDisplay";
99
import CaseDetails from "./CaseDetails";
1010
import CasesFetcher from "./CasesFetcher";
1111

@@ -21,7 +21,8 @@ const Cases: React.FC = () => (
2121
<Container>
2222
<Routes>
2323
<Route path="/display/:page/:order/:filter" element={<CasesFetcher />} />
24-
<Route path="/:id/evidence/attachment/*" element={<EvidenceAttachmentDisplay />} />
24+
<Route path="/:id/evidence/attachment/*" element={<AttachmentDisplay />} />
25+
<Route path="/:id/overview/policy/attachment/*" element={<AttachmentDisplay />} />
2526
<Route path="/:id/*" element={<CaseDetails />} />
2627
</Routes>
2728
</Container>

0 commit comments

Comments
 (0)