Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update polkadot tab total value, #1401 #1482

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 41 additions & 27 deletions landing/src/components/overview/content/summary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,15 @@ export default function OverviewSummary({ chain = "" }) {
</div>

<div>
<SummaryItem
className="justify-between py-2"
title="Available"
icon={<ImageWithDark src="/imgs/data-available.svg" />}
content={
chain === "polkadot" ? (
<SummaryItemTokenAmount
amount={treasuryData?.fiatValue}
symbol={"USDT"}
/>
) : (
<SummaryItemValueContent
amount={toPrecision(treasuryData?.balance, decimals, false)}
symbol={symbol}
symbolPrice={symbolPrice}
/>
)
}
/>
{chain === "polkadot" ? (
<SummaryItemTotal fiatValue={treasuryData?.fiatValue} />
) : (
<SummaryItemAvailable
amount={toPrecision(treasuryData?.balance, decimals, false)}
symbol={symbol}
symbolPrice={symbolPrice}
/>
)}
<SummaryItem
className="justify-between py-2"
title="Spend Period"
Expand Down Expand Up @@ -97,9 +87,7 @@ export default function OverviewSummary({ chain = "" }) {
</div>
}
/>

<hr className="my-4" />

<SummaryItem
className="justify-between py-2"
title="Total Income"
Expand Down Expand Up @@ -149,22 +137,48 @@ export default function OverviewSummary({ chain = "" }) {
);
}

function SummaryItemAvailable({ amount = 0, symbol = "", symbolPrice = 0 }) {
return (
<SummaryItem
className="justify-between py-2"
title="Available"
icon={<ImageWithDark src="/imgs/data-available.svg" />}
content={
<SummaryItemValueContent
amount={amount}
symbol={symbol}
symbolPrice={symbolPrice}
/>
}
/>
);
}

function SummaryItemValueContent({ amount = 0, symbol = "", symbolPrice = 0 }) {
return (
<div>
<SummaryItemTokenAmount amount={amount} symbol={symbol} />
<div className="flex items-center h3-18-semibold">
<div className="mr-1">{abbreviateBigNumber(amount)}</div>
<div className="text-textTertiary">{symbol}</div>
</div>
<div className="text-textTertiary p-12-normal">
{!!amount && "≈ "}${abbreviateBigNumber(amount * symbolPrice)}
</div>
</div>
);
}

function SummaryItemTokenAmount({ amount = 0, symbol = "" }) {
function SummaryItemTotal({ fiatValue = 0 }) {
return (
<div className="flex items-center h3-18-semibold">
<div className="mr-1">{abbreviateBigNumber(amount)}</div>
<div className="text-textTertiary">{symbol}</div>
</div>
<SummaryItem
className="justify-between py-2"
title="Total"
icon={<ImageWithDark src="/imgs/data-available.svg" />}
content={
<div className="flex items-center h3-18-semibold">
<div className="mr-1">≈ ${abbreviateBigNumber(fiatValue)}</div>
</div>
}
/>
);
}
Loading