Skip to content

Commit d9c3ed1

Browse files
committed
Merge branch 'fix(web)/court-ongoing-stats' of https://github.com/kleros/kleros-v2 into fix(web)/court-ongoing-stats
2 parents 8c7905e + 29a8733 commit d9c3ed1

File tree

19 files changed

+304
-33
lines changed

19 files changed

+304
-33
lines changed

web/src/assets/svgs/header/header-darkmode-desktop.svg

Lines changed: 73 additions & 0 deletions
Loading

web/src/assets/svgs/header/header-darkmode-mobile.svg

Lines changed: 53 additions & 0 deletions
Loading

web/src/assets/svgs/header/header-lightmode-desktop.svg

Lines changed: 15 additions & 0 deletions
Loading

web/src/assets/svgs/header/header-lightmode-mobile.svg

Lines changed: 53 additions & 0 deletions
Loading

web/src/assets/svgs/icons/user.svg

Lines changed: 1 addition & 1 deletion
Loading

web/src/components/ConnectWallet/AccountDisplay.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ import { shortenAddress } from "utils/shortenAddress";
66

77
const Container = styled.div`
88
display: flex;
9-
flex-direction: row;
10-
justify-content: space-between;
11-
align-content: center;
12-
align-items: center;
9+
flex-direction: column;
10+
align-items: flex-start;
11+
gap: 8px;
1312
`;
1413

1514
const AccountContainer = styled.div`

web/src/components/ConnectWallet/index.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import React from "react";
2+
import styled from "styled-components";
23
import { useAccount, useNetwork, useSwitchNetwork } from "wagmi";
34
import { useWeb3Modal } from "@web3modal/react";
45
import { Button } from "@kleros/ui-components-library";
56
import { SUPPORTED_CHAINS, DEFAULT_CHAIN } from "consts/chains";
67
import AccountDisplay from "./AccountDisplay";
8+
import { DisconnectWalletButton } from "layout/Header/navbar/Menu/Settings/General";
9+
10+
const Container = styled.div`
11+
display: flex;
12+
gap: 16px;
13+
justify-content: space-between;
14+
flex-wrap: wrap;
15+
align-items: center;
16+
`;
717

818
export const SwitchChainButton: React.FC = () => {
919
const { switchNetwork, isLoading } = useSwitchNetwork();
@@ -39,7 +49,13 @@ const ConnectWallet: React.FC = () => {
3949
if (isConnected) {
4050
if (chain && chain.id !== DEFAULT_CHAIN) {
4151
return <SwitchChainButton />;
42-
} else return <AccountDisplay />;
52+
} else
53+
return (
54+
<Container>
55+
<AccountDisplay />
56+
<DisconnectWalletButton />
57+
</Container>
58+
);
4359
} else return <ConnectButton />;
4460
};
4561

web/src/components/StatDisplay.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ const SVGContainer = styled.div<{ iconColor: string; backgroundColor: string }>`
1515
display: flex;
1616
align-items: center;
1717
justify-content: center;
18-
1918
svg {
2019
fill: ${({ iconColor }) => iconColor};
21-
height: 32px;
22-
width: 32px;
20+
height: ${({ iconColor, theme }) => (iconColor === theme.success ? "24px" : "32px")};
21+
width: ${({ iconColor, theme }) => (iconColor === theme.success ? "24px" : "32px")};
2322
}
2423
`;
2524

@@ -51,6 +50,7 @@ const StatDisplay: React.FC<IStatDisplay> = ({ title, text, subtext, icon: Icon,
5150
blue: createPair(theme.primaryBlue, theme.mediumBlue),
5251
purple: createPair(theme.secondaryPurple, theme.mediumPurple),
5352
};
53+
5454
return (
5555
<Container {...props}>
5656
<SVGContainer {...{ ...COLORS[color] }}>{<Icon />}</SVGContainer>

web/src/consts/coingecko.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// https://apiguide.coingecko.com/getting-started/10-min-tutorial-guide/1-get-data-by-id-or-address
2+
export const CoinIds = {
3+
ETH: "coingecko:ethereum",
4+
PNK: "coingecko:kleros",
5+
};

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import styled from "styled-components";
33
import { useParams } from "react-router-dom";
44
import { useCourtDetails, CourtDetailsQuery } from "queries/useCourtDetails";
55
import { useCoinPrice } from "hooks/useCoinPrice";
6-
import { usePNKAddress, useWETHAddress } from "hooks/useContractAddress";
76
import { formatETH, formatPNK, formatUnitsWei, formatUSD, isUndefined } from "utils/index";
87
import { calculateSubtextRender } from "utils/calculateSubtextRender";
8+
import { CoinIds } from "consts/coingecko";
99
import StatDisplay, { IStatDisplay } from "components/StatDisplay";
1010
import { StyledSkeleton } from "components/StyledSkeleton";
1111
import BalanceIcon from "svgs/icons/law-balance.svg";
@@ -86,7 +86,7 @@ const stats: IStat[] = [
8686
{
8787
title: "PNK redistributed",
8888
coinId: 0,
89-
getText: (data) => formatPNK(data?.paidPNK, 18),
89+
getText: (data) => formatPNK(data?.paidPNK),
9090
getSubtext: (data, coinPrice) => formatUSD(Number(formatUnitsWei(data?.paidPNK)) * (coinPrice ?? 0)),
9191
color: "purple",
9292
icon: PNKRedistributedIcon,
@@ -96,14 +96,13 @@ const stats: IStat[] = [
9696
const Stats = () => {
9797
const { id } = useParams();
9898
const { data } = useCourtDetails(id);
99-
const coinIdToAddress = [usePNKAddress(), useWETHAddress()];
100-
const { prices: pricesData } = useCoinPrice(coinIdToAddress);
99+
const coinIds = [CoinIds.PNK, CoinIds.ETH];
100+
const { prices: pricesData } = useCoinPrice(coinIds);
101101

102102
return (
103103
<StyledCard>
104104
{stats.map(({ title, coinId, getText, getSubtext, color, icon }, i) => {
105-
const coinPrice = !isUndefined(pricesData) ? pricesData[coinIdToAddress[coinId!]]?.price : undefined;
106-
105+
const coinPrice = !isUndefined(pricesData) ? pricesData[coinIds[coinId!]]?.price : undefined;
107106
return (
108107
<StatDisplay
109108
key={i}

0 commit comments

Comments
 (0)