-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
3 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
site/src/pages/Overview/polkadot/treasuryDetail/bounties.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Link as LinkOrigin } from "react-router-dom"; | ||
import { useBountiesData } from "../../../../hooks/bounties/useBountiesData"; | ||
import TreasuryDetailItem from "./common/item"; | ||
import { useBountiesTotalBalance } from "../../../../hooks/bounties/useBountiesBalances"; | ||
import ValueDisplay from "../../../../components/ValueDisplay"; | ||
import { currentChainSettings } from "../../../../utils/chains"; | ||
import styled from "styled-components"; | ||
import AssetWrapper from "./common/assetWrapper"; | ||
import AssetValueDisplay from "./common/assetValueDisplay"; | ||
import { overviewSelector } from "../../../../store/reducers/overviewSlice"; | ||
import { useSelector } from "react-redux"; | ||
import { toPrecision } from "../../../../utils"; | ||
import BigNumber from "bignumber.js"; | ||
import SkeletonBar from "../../../../components/skeleton/bar"; | ||
|
||
const Link = styled(LinkOrigin)` | ||
color: var(--textSecondary); | ||
&:hover { | ||
color: var(--textSecondary); | ||
text-decoration: underline; | ||
} | ||
`; | ||
|
||
// TODO: overview, loading effects | ||
export default function TreasuryDetailBounties() { | ||
const { bounties, bountiesCount } = useBountiesData(); | ||
const { balance, isLoading } = useBountiesTotalBalance(bounties); | ||
const overview = useSelector(overviewSelector); | ||
const dotPrice = overview?.latestSymbolPrice ?? 0; | ||
|
||
const total = toPrecision( | ||
BigNumber(balance).multipliedBy(dotPrice), | ||
currentChainSettings.decimals, | ||
); | ||
|
||
return ( | ||
<TreasuryDetailItem | ||
title={ | ||
<> | ||
<Link to="/bounties">Bounties</Link> · {bountiesCount} | ||
</> | ||
} | ||
titleTooltipContent="Funds for bounty programs" | ||
iconSrc="/imgs/data-bounties.svg" | ||
content={ | ||
isLoading ? ( | ||
<SkeletonBar width={64} height={28} /> | ||
) : ( | ||
<ValueDisplay value={total} precision={0} /> | ||
) | ||
} | ||
footer={ | ||
<AssetWrapper> | ||
<AssetValueDisplay | ||
symbol="dot" | ||
value={balance} | ||
precision={currentChainSettings.decimals} | ||
/> | ||
</AssetWrapper> | ||
} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters