Skip to content

Commit 164b1e2

Browse files
committed
frontend: fix sats unit in all-accounts tab
When sats mode is enabled, the all accounts tab on mobile showed the value in satohis but with the wrong unit. It used the account unit instead of the balance unit. `hasAvailable` does not need to be checked, it means balance is `>0`, but we show the balance regardless of it is 0 or larger.
1 parent 040bc84 commit 164b1e2

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

frontends/web/src/routes/accounts/all-accounts.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type AllAccountsProps = {
3737
};
3838

3939
const AccountItem = ({ account, hideAmounts }: { account: accountApi.IAccount, hideAmounts: boolean }) => {
40-
const [balance, setBalance] = useState<string>('');
40+
const [balance, setBalance] = useState<accountApi.TAmountWithConversions>();
4141
const mounted = useMountedRef();
4242

4343
useEffect(() => {
@@ -48,14 +48,10 @@ const AccountItem = ({ account, hideAmounts }: { account: accountApi.IAccount, h
4848
return;
4949
}
5050
if (!balance.success) {
51+
setBalance(undefined);
5152
return;
5253
}
53-
const balanceData = balance.balance;
54-
if (balanceData.hasAvailable) {
55-
setBalance(balanceData.available.amount);
56-
} else {
57-
setBalance('0');
58-
}
54+
setBalance(balance.balance.available);
5955
} catch (error) {
6056
console.error('Failed to fetch balance for account', account.code, error);
6157
}
@@ -75,10 +71,10 @@ const AccountItem = ({ account, hideAmounts }: { account: accountApi.IAccount, h
7571

7672
<div className={styles.accountBalanceContainer}>
7773
<div className={styles.accountBalance}>
78-
{balance ? (hideAmounts ? '***' : balance) : '...'}
74+
{balance ? (hideAmounts ? '***' : balance.amount) : '...'}
7975
</div>
8076
<div className={styles.coinUnit}>
81-
{balance ? account.coinUnit : ''}
77+
{balance ? balance.unit : ''}
8278
</div>
8379
</div>
8480
<div className={styles.chevron}>

0 commit comments

Comments
 (0)