Skip to content

Commit 30f85f3

Browse files
authored
Merge pull request #1089 from kleros/fix(web)/dashboard-data-and-wallet-connection
fix: dashboard-data-and-wallet-connection
2 parents 2ade29e + 10a65b6 commit 30f85f3

File tree

4 files changed

+76
-16
lines changed

4 files changed

+76
-16
lines changed
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import React from "react";
2+
import styled, { css } from "styled-components";
3+
4+
const LinearGradientPath = styled.path<{ gradient: string }>`
5+
${({ gradient }) =>
6+
gradient &&
7+
css`
8+
stroke: url(#${gradient});
9+
`}
10+
`;
11+
12+
interface IGradientTokenIcons {
13+
icon: string;
14+
}
15+
16+
const GradientTokenIcons: React.FC<IGradientTokenIcons> = ({ icon }) => {
17+
return (
18+
<>
19+
{icon === "ETH" ? (
20+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
21+
<LinearGradientPath
22+
gradient="eth"
23+
id="paint0_linear_14360_27088"
24+
d="M9.86602 28.0687L22.923 36.0836V47.1905L9.86602 28.0687ZM23.423 36.0836L36.4799 28.0687L23.423 47.1905V36.0836ZM23.423 16.428V0.930308L36.666 23.7911L23.423 16.428ZM36.8415 24.4607L23.423 32.703V17L36.8415 24.4607ZM22.923 0.929777V16.4279L9.67081 23.7913L22.923 0.929777ZM22.923 32.7032L9.49539 24.4607L22.923 16.9999V32.7032Z"
25+
/>
26+
<defs>
27+
<linearGradient id="eth" x1="23.173" y1="0" x2="23.173" y2="48" gradientUnits="userSpaceOnUse">
28+
<stop stopColor="#6CC5FF" />
29+
<stop offset="1" stopColor="#B45FFF" />
30+
</linearGradient>
31+
</defs>
32+
</svg>
33+
) : (
34+
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
35+
<LinearGradientPath
36+
gradient="pnk"
37+
fillRule="evenodd"
38+
clipRule="evenodd"
39+
d="M15.7151 6L35.6632 7.30096L43.9078 25.526L32.6361 42L12.2385 41.132L4 21.1862L15.7151 6ZM16.2222 7.03373L13.1105 22.2033L31.3917 13.6461L16.2222 7.03373ZM31.8965 14.3445L13.3445 23.0284L29.1334 34.8701L31.8965 14.3445ZM28.5319 35.4771L12.9497 23.7905V40.1518L28.5319 35.4771ZM12.1032 38.5872V23.2874L5.18188 21.8302L12.1032 38.5872ZM5.23158 20.9756L12.1974 22.4421L15.1303 8.14394L5.23158 20.9756ZM15.0532 40.4045L31.7195 41.1137L29.2373 36.1493L15.0532 40.4045ZM29.9956 35.773L32.4763 40.7345L41.6905 27.2676L29.9956 35.773ZM41.9695 23.295L35.3631 8.69144L32.9292 13.5593L41.9695 23.295ZM32.2205 13.0839L18.3024 7.01704L34.7186 8.08766L32.2205 13.0839ZM32.7193 14.5773L30.0082 34.7171L42.7892 25.4218L32.7193 14.5773Z"
40+
fill="url(#paint0_linear_14360_27090)"
41+
/>
42+
<defs>
43+
<linearGradient id="pnk" x1="23.9539" y1="6" x2="23.9539" y2="42" gradientUnits="userSpaceOnUse">
44+
<stop stopColor="#6CC5FF" />
45+
<stop offset="1" stopColor="#B45FFF" />
46+
</linearGradient>
47+
</defs>
48+
</svg>
49+
)}
50+
</>
51+
);
52+
};
53+
export default GradientTokenIcons;

web/src/context/Web3Provider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const { publicClient, webSocketPublicClient } = configureChains(chains, [
2222
]);
2323

2424
const wagmiConfig = createConfig({
25-
autoConnect: false,
25+
autoConnect: true,
2626
connectors: w3mConnectors({ projectId, version: 2, chains }),
2727
publicClient,
2828
webSocketPublicClient,

web/src/pages/Dashboard/JurorInfo/Coherency.tsx

+20-4
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,38 @@ const tooltipMsg =
1818
" using the number of times you have been coherent and the total cases you" +
1919
" have been in.";
2020

21+
const levelTitles = [
22+
{ scoreRange: [0, 20], level: 0, title: "Diogenes" },
23+
{ scoreRange: [20, 40], level: 1, title: "Pythagoras" },
24+
{ scoreRange: [40, 60], level: 2, title: "Socrates" },
25+
{ scoreRange: [60, 80], level: 3, title: "Plato" },
26+
{ scoreRange: [80, 100], level: 4, title: "Aristotle" },
27+
];
28+
2129
const Coherency: React.FC = () => {
2230
const { address } = useAccount();
2331
const { data } = useUserQuery(address?.toLowerCase());
2432
const totalCoherent = parseInt(data?.user?.totalCoherent) ?? 0;
2533
const totalResolvedDisputes = parseInt(data?.user?.totalResolvedDisputes) ?? 1;
2634
const coherencyScore = calculateCoherencyScore(totalCoherent, totalResolvedDisputes);
35+
const roundedCoherencyScore = Math.round(coherencyScore * 100);
36+
37+
const { level, title } =
38+
levelTitles.find(({ scoreRange }) => {
39+
return roundedCoherencyScore >= scoreRange[0] && roundedCoherencyScore < scoreRange[1];
40+
}) ?? levelTitles[0];
2741

2842
return (
2943
<Container>
30-
<small>Aristotle</small>
31-
<label>Level 4</label>
32-
<CircularProgress progress={(totalCoherent / Math.max(totalResolvedDisputes, 1)) * 100} />
44+
<small>{title}</small>
45+
<label>Level {level}</label>
46+
<CircularProgress
47+
progress={parseFloat(((totalCoherent / Math.max(totalResolvedDisputes, 1)) * 100).toFixed(2))}
48+
/>
3349
<WithHelpTooltip place="left" {...{ tooltipMsg }}>
3450
<label>
3551
Coherency Score:
36-
<small> {coherencyScore.toFixed(3)} </small>
52+
<small> {coherencyScore.toFixed(2)} </small>
3753
</label>
3854
</WithHelpTooltip>
3955
</Container>

web/src/pages/Dashboard/JurorInfo/TokenRewards.tsx

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import styled from "styled-components";
3-
import _ETH from "assets/svgs/styled/eth.svg";
4-
import _PNK from "assets/svgs/styled/pnk.svg";
3+
import GradientTokenIcons from "components/GradientTokenIcons";
54

65
const RewardContainer = styled.div`
76
display: flex;
@@ -10,14 +9,6 @@ const RewardContainer = styled.div`
109
gap: 8px;
1110
`;
1211

13-
const ETH = styled(_ETH)`
14-
stroke: ${({ theme }) => theme.secondaryBlue};
15-
`;
16-
17-
const PNK = styled(_PNK)`
18-
stroke: ${({ theme }) => theme.secondaryBlue};
19-
`;
20-
2112
const StyledH1 = styled.h1`
2213
margin: 0;
2314
`;
@@ -31,7 +22,7 @@ interface ITokenRewards {
3122
const TokenRewards: React.FC<ITokenRewards> = ({ token, amount, value }) => {
3223
return (
3324
<RewardContainer>
34-
{token === "ETH" ? <ETH /> : <PNK />}
25+
{token && <GradientTokenIcons icon={token} />}
3526
<StyledH1>
3627
{amount} {token}
3728
</StyledH1>

0 commit comments

Comments
 (0)