Skip to content

Commit 2a92d72

Browse files
committed
feat: add extra myprofile link in navbar, add extra mycases link in cases page, fix tiny padding iss
1 parent fb2da0b commit 2a92d72

File tree

3 files changed

+49
-25
lines changed

3 files changed

+49
-25
lines changed

web/src/components/CasesDisplay/index.tsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import styled from "styled-components";
33

44
import { useLocation } from "react-router-dom";
5+
import { useAccount } from "wagmi";
56

67
import ArrowIcon from "svgs/icons/arrow.svg";
78

@@ -29,6 +30,12 @@ const StyledLabel = styled.label`
2930
font-size: ${responsiveSize(14, 16)};
3031
`;
3132

33+
const LinksContainer = styled.div`
34+
display: flex;
35+
flex-direction: row;
36+
gap: 16px;
37+
`;
38+
3239
interface ICasesDisplay extends ICasesGrid {
3340
numberDisputes?: number;
3441
numberClosedDisputes?: number;
@@ -48,15 +55,25 @@ const CasesDisplay: React.FC<ICasesDisplay> = ({
4855
totalPages,
4956
}) => {
5057
const location = useLocation();
58+
const { isConnected, address } = useAccount();
59+
const profileLink = isConnected && address ? `/profile/1/desc/all?address=${address}` : null;
60+
5161
return (
5262
<div {...{ className }}>
5363
<TitleContainer className="title">
5464
<StyledTitle>{title}</StyledTitle>
55-
{location.pathname.startsWith("/cases/display/1/desc/all") ? (
56-
<StyledArrowLink to={"/resolver"}>
57-
Create a case <ArrowIcon />
58-
</StyledArrowLink>
59-
) : null}
65+
<LinksContainer>
66+
{location.pathname.startsWith("/cases/display") && profileLink ? (
67+
<StyledArrowLink to={profileLink}>
68+
My Cases <ArrowIcon />
69+
</StyledArrowLink>
70+
) : null}
71+
{location.pathname.startsWith("/cases/display") ? (
72+
<StyledArrowLink to={"/resolver"}>
73+
Create a case <ArrowIcon />
74+
</StyledArrowLink>
75+
) : null}
76+
</LinksContainer>
6077
</TitleContainer>
6178
<Search />
6279
<StatsAndFilters totalDisputes={numberDisputes || 0} closedDisputes={numberClosedDisputes || 0} />

web/src/layout/Header/navbar/Explore.tsx

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import React from "react";
1+
import React, { useMemo } from "react";
22
import styled, { css } from "styled-components";
33
import { landscapeStyle } from "styles/landscapeStyle";
44

55
import { Link, useLocation } from "react-router-dom";
6+
import { useAccount } from "wagmi";
67

78
import { useOpenContext } from "../MobileHeader";
89

@@ -50,35 +51,41 @@ const StyledLink = styled(Link)<{ isActive: boolean; isMobileNavbar?: boolean }>
5051
)};
5152
`;
5253

53-
const links = [
54-
{ to: "/", text: "Home" },
55-
{ to: "/cases/display/1/desc/all", text: "Cases" },
56-
{ to: "/courts", text: "Courts" },
57-
{ to: "/jurors/1/desc/all", text: "Jurors" },
58-
{ to: "/get-pnk", text: "Get PNK" },
59-
];
60-
6154
interface IExplore {
6255
isMobileNavbar?: boolean;
6356
}
6457

6558
const Explore: React.FC<IExplore> = ({ isMobileNavbar }) => {
6659
const location = useLocation();
6760
const { toggleIsOpen } = useOpenContext();
61+
const { isConnected, address } = useAccount();
62+
63+
const navLinks = useMemo(() => {
64+
const base = [
65+
{ to: "/", text: "Home" },
66+
{ to: "/cases/display/1/desc/all", text: "Cases" },
67+
{ to: "/courts", text: "Courts" },
68+
{ to: "/jurors/1/desc/all", text: "Jurors" },
69+
{ to: "/get-pnk", text: "Get PNK" },
70+
];
71+
if (isConnected && address) {
72+
base.push({ to: `/profile/1/desc/all?address=${address}`, text: "My Profile" });
73+
}
74+
return base;
75+
}, [isConnected, address]);
6876

6977
return (
7078
<Container>
7179
<Title>Explore</Title>
72-
{links.map(({ to, text }) => (
73-
<StyledLink
74-
key={text}
75-
onClick={toggleIsOpen}
76-
isActive={to === "/" ? location.pathname === "/" : location.pathname.split("/")[1] === to.split("/")[1]}
77-
{...{ to, isMobileNavbar }}
78-
>
79-
{text}
80-
</StyledLink>
81-
))}
80+
{navLinks.map(({ to, text }) => {
81+
const pathBase = to.split("?")[0];
82+
const isActive = pathBase === "/" ? location.pathname === "/" : location.pathname.startsWith(pathBase);
83+
return (
84+
<StyledLink key={text} onClick={toggleIsOpen} isActive={isActive} {...{ to, isMobileNavbar }}>
85+
{text}
86+
</StyledLink>
87+
);
88+
})}
8289
</Container>
8390
);
8491
};

web/src/pages/Courts/CourtDetails/Stats/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { landscapeStyle } from "styles/landscapeStyle";
1616
import StatsContent from "./StatsContent";
1717

1818
const Container = styled.div`
19-
padding: 12px 24px;
19+
padding: 0 24px 12px 24px;
2020
`;
2121

2222
const Header = styled.h3`

0 commit comments

Comments
 (0)