Skip to content

Commit 574f8c9

Browse files
committed
feat: add new section latest stakes in this court, substitute the profile page too
1 parent 3342328 commit 574f8c9

File tree

16 files changed

+867
-31
lines changed

16 files changed

+867
-31
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { useQuery } from "@tanstack/react-query";
2+
import { request } from "graphql-request";
3+
4+
import { isUndefined } from "src/utils";
5+
6+
export type StakingEventItem = {
7+
id: string;
8+
blockHash: string;
9+
transactionHash: string;
10+
blockTimestamp: string;
11+
network: {
12+
chainId: number;
13+
};
14+
args: {
15+
_address: string;
16+
_courtID: string;
17+
_amount: string;
18+
};
19+
};
20+
21+
type StakingEventsResponse = {
22+
userStakingEvents: {
23+
items: Array<{ item: StakingEventItem }>;
24+
count: number;
25+
};
26+
};
27+
28+
const atlasUri = import.meta.env.REACT_APP_ATLAS_URI;
29+
30+
export const useStakingEventsByCourt = (courtIds: number[], skip: number, take: number, partialAddress?: string) => {
31+
const addressParam = partialAddress ?? "";
32+
// Allow empty courtIds array for "all courts" query
33+
const isEnabled = !isUndefined(atlasUri);
34+
35+
const query = `
36+
query GetStakingEvents($partialAddress: String!, $courtIDs: [Int!], $pagination: PaginationArgs) {
37+
userStakingEvents(partialAddress: $partialAddress, courtIDs: $courtIDs, pagination: $pagination) {
38+
items {
39+
item {
40+
id
41+
blockHash
42+
transactionHash
43+
blockTimestamp
44+
network {
45+
chainId
46+
}
47+
args {
48+
_address
49+
_courtID
50+
_amount
51+
}
52+
}
53+
}
54+
count
55+
}
56+
}
57+
`;
58+
59+
const variables = {
60+
partialAddress: addressParam,
61+
// If courtIds is empty, pass null to query all courts
62+
courtIDs: courtIds.length > 0 ? courtIds : null,
63+
pagination: { skip, take },
64+
};
65+
66+
return useQuery<StakingEventsResponse>({
67+
queryKey: ["stakingEventsByCourt", courtIds, skip, take, partialAddress],
68+
enabled: isEnabled,
69+
staleTime: 60000,
70+
queryFn: async () => {
71+
return await request<StakingEventsResponse>(`${atlasUri}/graphql`, query, variables);
72+
},
73+
});
74+
};

web/src/pages/Courts/CourtDetails/JurorsStakedByCourt/DisplayJurors/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Container = styled.div`
1010
border: 1px solid ${({ theme }) => theme.stroke};
1111
border-top-left-radius: 3px;
1212
border-top-right-radius: 3px;
13-
padding: 18px 24px;
13+
padding: 16px 20px;
1414
justify-content: space-between;
1515
margin-top: ${responsiveSize(12, 16)};
1616
`;

web/src/pages/Courts/CourtDetails/JurorsStakedByCourt/DisplayJurors/JurorCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Container = styled.div`
1616
border: 1px solid ${({ theme }) => theme.stroke};
1717
border-top: none;
1818
align-items: center;
19-
padding: 18px 24px;
19+
padding: 16px 20px;
2020
2121
:hover {
2222
background-color: ${({ theme }) => theme.lightGrey}BB;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import React from "react";
22
import styled from "styled-components";
33

4-
import { responsiveSize } from "styles/responsiveSize";
5-
64
import { getDescriptiveCourtName } from "utils/getDescriptiveCourtName";
75

8-
import Search from "./Search";
6+
import { responsiveSize } from "styles/responsiveSize";
7+
98
import DisplayJurors from "./DisplayJurors";
9+
import Search from "./Search";
1010

1111
const Container = styled.div`
12-
margin-top: ${responsiveSize(28, 48)};
1312
max-width: 578px;
1413
`;
1514

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from "react";
2+
3+
import { DesktopHeader } from "./Header/DesktopHeader";
4+
5+
const Header: React.FC = () => {
6+
return <DesktopHeader />;
7+
};
8+
9+
export default Header;
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import React from "react";
2+
import styled, { css } from "styled-components";
3+
4+
import { landscapeStyle } from "styles/landscapeStyle";
5+
import { responsiveSize } from "styles/responsiveSize";
6+
7+
import WithHelpTooltip from "components/WithHelpTooltip";
8+
9+
const Container = styled.div`
10+
display: none;
11+
width: 100%;
12+
background-color: ${({ theme }) => theme.lightBlue};
13+
border: 1px solid ${({ theme }) => theme.stroke};
14+
border-top-left-radius: 3px;
15+
border-top-right-radius: 3px;
16+
padding: 16px 20px;
17+
margin-top: ${responsiveSize(12, 16)};
18+
gap: 12px;
19+
20+
${landscapeStyle(
21+
() => css`
22+
display: flex;
23+
`
24+
)}
25+
`;
26+
27+
const StyledLabel = styled.label`
28+
font-size: 14px;
29+
color: ${({ theme }) => theme.secondaryText};
30+
`;
31+
32+
const JurorLabel = styled(StyledLabel)`
33+
flex: 1;
34+
min-width: 150px;
35+
text-align: left;
36+
`;
37+
38+
const StakeLabel = styled(StyledLabel)`
39+
width: 90px;
40+
text-align: right;
41+
flex-shrink: 0;
42+
`;
43+
44+
const CourtLabelContainer = styled.div`
45+
width: 110px;
46+
flex-shrink: 0;
47+
display: flex;
48+
justify-content: flex-end;
49+
align-items: center;
50+
`;
51+
52+
const CourtLabel = styled(StyledLabel)`
53+
text-align: right;
54+
`;
55+
56+
const DateLabel = styled(StyledLabel)`
57+
width: 120px;
58+
text-align: right;
59+
flex-shrink: 0;
60+
`;
61+
62+
const courtTooltipMsg =
63+
"When you are staked in a subcourt you are staked in its parent courts too. eg. Staking in the Non Technical court automatically stake in its parents: Blockchain, and General Court.";
64+
65+
export const DesktopHeader: React.FC = () => {
66+
return (
67+
<Container>
68+
<JurorLabel>Juror</JurorLabel>
69+
<StakeLabel>PNK Staked</StakeLabel>
70+
<CourtLabelContainer>
71+
<WithHelpTooltip place="top" tooltipMsg={courtTooltipMsg}>
72+
<CourtLabel>Court</CourtLabel>
73+
</WithHelpTooltip>
74+
</CourtLabelContainer>
75+
<DateLabel>Date</DateLabel>
76+
</Container>
77+
);
78+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from "react";
2+
import styled, { css } from "styled-components";
3+
4+
import { landscapeStyle } from "styles/landscapeStyle";
5+
import { responsiveSize } from "styles/responsiveSize";
6+
7+
const Container = styled.div`
8+
display: flex;
9+
width: 100%;
10+
background-color: ${({ theme }) => theme.lightBlue};
11+
border: 1px solid ${({ theme }) => theme.stroke};
12+
border-top-left-radius: 3px;
13+
border-top-right-radius: 3px;
14+
padding: 16px;
15+
margin-top: ${responsiveSize(12, 16)};
16+
17+
${landscapeStyle(
18+
() => css`
19+
display: none;
20+
`
21+
)}
22+
`;
23+
24+
const StyledLabel = styled.label`
25+
font-size: 14px;
26+
color: ${({ theme }) => theme.secondaryText};
27+
`;
28+
29+
export const MobileHeader: React.FC = () => {
30+
return (
31+
<Container>
32+
<StyledLabel>Latest Stakes</StyledLabel>
33+
</Container>
34+
);
35+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from "react";
2+
3+
import DesktopCard from "./StakeEventCard/DesktopCard";
4+
import MobileCard from "./StakeEventCard/MobileCard";
5+
6+
interface IStakeEventCard {
7+
address: string;
8+
stake: string;
9+
timestamp: string;
10+
transactionHash: string;
11+
courtName: string;
12+
courtId: number;
13+
currentCourtId?: number;
14+
}
15+
16+
const StakeEventCard: React.FC<IStakeEventCard> = ({
17+
address,
18+
stake,
19+
timestamp,
20+
transactionHash,
21+
courtName,
22+
courtId,
23+
currentCourtId,
24+
}) => {
25+
const allProps = { address, stake, timestamp, transactionHash, courtName, courtId, currentCourtId };
26+
27+
return (
28+
<>
29+
<MobileCard {...allProps} />
30+
<DesktopCard {...allProps} />
31+
</>
32+
);
33+
};
34+
35+
export default StakeEventCard;

0 commit comments

Comments
 (0)