From d42181188769a167679127d64048630a862b2777 Mon Sep 17 00:00:00 2001 From: Yusef Habib Fernandez Date: Wed, 8 Jan 2025 18:22:22 +0100 Subject: [PATCH] WIP --- frontend/src/lib/pages/Portfolio.svelte | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/frontend/src/lib/pages/Portfolio.svelte b/frontend/src/lib/pages/Portfolio.svelte index 1163a37de0..7c04097a81 100644 --- a/frontend/src/lib/pages/Portfolio.svelte +++ b/frontend/src/lib/pages/Portfolio.svelte @@ -4,6 +4,32 @@ import NoNeuronsCard from "$lib/components/portfolio/NoNeuronsCard.svelte"; import NoTokensCard from "$lib/components/portfolio/NoTokensCard.svelte"; import { authSignedInStore } from "$lib/derived/auth.derived"; + import type { UserToken } from "$lib/types/tokens-page"; + import { getTotalBalanceInUsd } from "$lib/utils/token.utils"; + import { TokenAmountV2, isNullish } from "@dfinity/utils"; + + export let userTokensData: UserToken[]; + + let totalTokensBalanceInUsd: number; + $: totalTokensBalanceInUsd = getTotalBalanceInUsd(userTokensData); + + let hasUnpricedTokens: boolean; + $: hasUnpricedTokens = userTokensData.some( + (token) => + token.balance instanceof TokenAmountV2 && + token.balance.toUlps() > 0n && + (!("balanceInUsd" in token) || isNullish(token.balanceInUsd)) + ); + + let totalUsdAmount: number; + $: totalUsdAmount = $authSignedInStore ? totalTokensBalanceInUsd : undefined; + + let isNotSignedIn: boolean; + $: isNotSignedIn = !$authSignedInStore; + let showNoTokensCard: boolean; + $: showNoTokensCard = isNotSignedIn || totalTokenBalanceInUsd === 0; + let showNoNeuronsCard: boolean; + $: showNoNeuronsCard = isNotSignedIn || totalStakedInUsd === 0;