Skip to content

Commit c3213ca

Browse files
committed
feat: url path tab logic, refactors, add voted ballot svg, add icons to tabs
1 parent 45bc1fb commit c3213ca

File tree

22 files changed

+146
-78
lines changed

22 files changed

+146
-78
lines changed

web/src/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const App: React.FC = () => {
7373
}
7474
/>
7575
<Route
76-
path="profile/:page/:order/:filter"
76+
path="profile/*"
7777
element={
7878
<Suspense fallback={<Loader width={"48px"} height={"48px"} />}>
7979
<Profile />
Lines changed: 5 additions & 0 deletions
Loading

web/src/components/EvidenceCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ const EvidenceCard: React.FC<IEvidenceCard> = ({
223223
description,
224224
fileURI,
225225
}) => {
226-
const profileLink = `/profile/1/desc/all?address=${sender}`;
226+
const profileLink = `/profile/stakes?address=${sender}`;
227227

228228
const transactionExplorerLink = useMemo(() => {
229229
return getTxnExplorerLink(transactionHash ?? "");

web/src/components/JurorLink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ const JurorLink: React.FC<IJurorLink> = ({ address, isInternalLink = true }) =>
4949
const { isConnected, address: connectedAddress } = useAccount();
5050
const profileLink =
5151
isConnected && connectedAddress?.toLowerCase() === address.toLowerCase()
52-
? "/profile/1/desc/all"
53-
: `/profile/1/desc/all?address=${address}`;
52+
? "/profile"
53+
: `/profile/stakes?address=${address}`;
5454
const addressExplorerLink = useMemo(() => {
5555
return `${getChain(DEFAULT_CHAIN)?.blockExplorers?.default.url}/address/${address}`;
5656
}, [address]);

web/src/components/Popup/MiniGuides/JurorLevels.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Card as _Card } from "@kleros/ui-components-library";
55

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

8-
import Coherence from "pages/Profile/JurorInfo/BottomContent/Coherence";
9-
import PixelArt from "pages/Profile/JurorInfo/BottomContent/PixelArt";
8+
import Coherence from "pages/Profile/JurorCard/BottomContent/Coherence";
9+
import PixelArt from "pages/Profile/JurorCard/BottomContent/PixelArt";
1010

1111
import Template from "./MainStructureTemplate";
1212
import { Title, ParagraphsContainer, LeftContentContainer } from "./PageContentsTemplate";

web/src/layout/Header/navbar/Menu/Settings/General/WalletAndProfile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const WalletAndProfile: React.FC<ISettings> = ({ toggleIsSettingsOpen }) => {
5252
<IdenticonOrAvatar />
5353
<AddressOrName />
5454
</AvatarAndAddressContainer>
55-
<ReStyledArrowLink to={"/profile/1/desc/all"} onClick={toggleIsSettingsOpen}>
55+
<ReStyledArrowLink to={"/profile"} onClick={toggleIsSettingsOpen}>
5656
My Profile <ArrowIcon />
5757
</ReStyledArrowLink>
5858
</Container>

web/src/pages/Cases/CaseDetails/Voting/VotesDetails/AccordionTitle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const AccordionTitle: React.FC<{
8686
commited: boolean;
8787
hiddenVotes: boolean;
8888
}> = ({ juror, choice, voteCount, period, answers, isActiveRound, commited, hiddenVotes }) => {
89-
const profileLink = `/profile/1/desc/all?address=${juror}`;
89+
const profileLink = `/profile/stakes?address=${juror}`;
9090

9191
return (
9292
<TitleContainer>

web/src/pages/Home/TopJurors/JurorCard/JurorLevel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { landscapeStyle } from "styles/landscapeStyle";
66
import { getUserLevelData } from "utils/userLevelCalculation";
77
import { getCoherencePercent } from "utils/getCoherencePercent";
88

9-
import PixelArt from "pages/Profile/JurorInfo/BottomContent/PixelArt";
9+
import PixelArt from "pages/Profile/JurorCard/BottomContent/PixelArt";
1010

1111
const Container = styled.div`
1212
display: flex;

web/src/pages/Jurors/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const Jurors: React.FC = () => {
5555
<Header>
5656
<StyledTitle>Jurors Leaderboard</StyledTitle>
5757
{isConnected ? (
58-
<StyledArrowLink to="/profile/1/desc/all">
58+
<StyledArrowLink to="/profile">
5959
My Profile <ArrowIcon />
6060
</StyledArrowLink>
6161
) : null}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React, { useMemo } from "react";
2+
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
3+
4+
import styled from "styled-components";
5+
import { responsiveSize } from "styles/responsiveSize";
6+
7+
import { isUndefined } from "utils/index";
8+
import { decodeURIFilter, useRootPath } from "utils/uri";
9+
10+
import { DisputeDetailsFragment, OrderDirection } from "src/graphql/graphql";
11+
import { useMyCasesQuery } from "queries/useCasesQuery";
12+
import { useUserQuery } from "queries/useUser";
13+
import CasesDisplay from "components/CasesDisplay";
14+
15+
const StyledCasesDisplay = styled(CasesDisplay)`
16+
margin-top: ${responsiveSize(24, 32)};
17+
18+
.title {
19+
margin-bottom: ${responsiveSize(12, 24)};
20+
}
21+
`;
22+
23+
interface ICases {
24+
addressToQuery: `0x${string}`;
25+
}
26+
27+
const Cases: React.FC<ICases> = ({ addressToQuery }) => {
28+
const { page, order, filter } = useParams();
29+
const [searchParams] = useSearchParams();
30+
const location = useRootPath();
31+
const navigate = useNavigate();
32+
33+
const casesPerPage = 3;
34+
const pageNumber = parseInt(page ?? "1");
35+
const disputeSkip = casesPerPage * (pageNumber - 1);
36+
const decodedFilter = decodeURIFilter(filter ?? "all");
37+
const { data: disputesData } = useMyCasesQuery(
38+
addressToQuery,
39+
disputeSkip,
40+
decodedFilter,
41+
order === "asc" ? OrderDirection.Asc : OrderDirection.Desc
42+
);
43+
44+
const { data: userData } = useUserQuery(addressToQuery, decodedFilter);
45+
const totalCases = userData?.user?.disputes.length;
46+
const totalResolvedCases = parseInt(userData?.user?.totalResolvedDisputes);
47+
const totalPages = useMemo(
48+
() => (!isUndefined(totalCases) ? Math.ceil(totalCases / casesPerPage) : 1),
49+
[totalCases, casesPerPage]
50+
);
51+
52+
return (
53+
<StyledCasesDisplay
54+
title="Cases Drawn"
55+
disputes={userData?.user !== null ? (disputesData?.user?.disputes as DisputeDetailsFragment[]) : []}
56+
numberDisputes={totalCases}
57+
numberClosedDisputes={totalResolvedCases}
58+
totalPages={totalPages}
59+
currentPage={pageNumber}
60+
setCurrentPage={(newPage: number) =>
61+
navigate(`${location}/${newPage}/${order}/${filter}?${searchParams.toString()}`)
62+
}
63+
{...{ casesPerPage }}
64+
/>
65+
);
66+
};
67+
68+
export default Cases;

0 commit comments

Comments
 (0)