profile refactor
This commit is contained in:
@@ -95,8 +95,9 @@ export interface OrgAmountRaw {
|
|||||||
raw: string
|
raw: string
|
||||||
formatted: string
|
formatted: string
|
||||||
decimals: number
|
decimals: number
|
||||||
usd_price: string
|
// null when pricing is unavailable (e.g. an upstream provider error).
|
||||||
usd_value: string
|
usd_price: string | null
|
||||||
|
usd_value: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrgWalletBalance {
|
export interface OrgWalletBalance {
|
||||||
@@ -107,13 +108,14 @@ export interface OrgWalletBalance {
|
|||||||
native_symbol: string
|
native_symbol: string
|
||||||
native: OrgAmountRaw
|
native: OrgAmountRaw
|
||||||
tokens: Record<string, OrgAmountRaw>
|
tokens: Record<string, OrgAmountRaw>
|
||||||
total_usd: string
|
// null when the wallet's balance could not be fetched (see `error`).
|
||||||
|
total_usd: string | null
|
||||||
error: string | null
|
error: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrgBalancesResponse {
|
export interface OrgBalancesResponse {
|
||||||
items: OrgWalletBalance[]
|
items: OrgWalletBalance[]
|
||||||
total_usd: string
|
total_usd: string | null
|
||||||
has_errors: boolean
|
has_errors: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useWalletBalance, usePortfolio, CHAINS } from '@features/wallet'
|
import { useWalletBalance, usePortfolio, CHAINS } from '@features/wallet'
|
||||||
import type { Chain, FormattedAmount } from '@features/wallet'
|
import type { Chain, FormattedAmount } from '@features/wallet'
|
||||||
|
import { useMe } from '@features/auth'
|
||||||
import { getCoinIcon } from '@shared/assets/coins'
|
import { getCoinIcon } from '@shared/assets/coins'
|
||||||
import { truncateDecimals } from '@shared/lib/utils/truncateDecimals'
|
import { truncateDecimals } from '@shared/lib/utils/truncateDecimals'
|
||||||
import { TOKENS, type Token } from './tokens'
|
import { TOKENS, type Token } from './tokens'
|
||||||
@@ -95,6 +96,13 @@ export function useChainTokenRows(chain: Chain) {
|
|||||||
|
|
||||||
export function useAllWalletTokenRows() {
|
export function useAllWalletTokenRows() {
|
||||||
const { data, isLoading } = usePortfolio()
|
const { data, isLoading } = usePortfolio()
|
||||||
|
const { data: me } = useMe()
|
||||||
|
|
||||||
|
// Legal-entity portfolios return a fixed catalog of supported tokens that are
|
||||||
|
// usually all zero for a fresh account. Filtering out zero balances would
|
||||||
|
// leave this aggregate view blank, so show every wallet/token (matching the
|
||||||
|
// per-chain pages). Individuals keep the non-zero-only view to avoid clutter.
|
||||||
|
const showAll = me?.account_type === 'legal_entity'
|
||||||
|
|
||||||
if (!data) return { rows: [] as Token[], isLoading }
|
if (!data) return { rows: [] as Token[], isLoading }
|
||||||
|
|
||||||
@@ -106,12 +114,12 @@ export function useAllWalletTokenRows() {
|
|||||||
|
|
||||||
const chainRows: Token[] = []
|
const chainRows: Token[] = []
|
||||||
|
|
||||||
if (chainData.native && hasBalance(chainData.native)) {
|
if (chainData.native && (showAll || hasBalance(chainData.native))) {
|
||||||
chainRows.push(nativeRowFor(chain, chainData.native))
|
chainRows.push(nativeRowFor(chain, chainData.native))
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const [symbol, amount] of Object.entries(chainData.tokens ?? {})) {
|
for (const [symbol, amount] of Object.entries(chainData.tokens ?? {})) {
|
||||||
if (!hasBalance(amount)) continue
|
if (!showAll && !hasBalance(amount)) continue
|
||||||
chainRows.push(tokenRowFor(chain, symbol, amount))
|
chainRows.push(tokenRowFor(chain, symbol, amount))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user