Skip to content

Commit 487b973

Browse files
committed
fix(perps): show the picked funding account without a countervalue
1 parent f874583 commit 487b973

2 files changed

Lines changed: 39 additions & 14 deletions

File tree

apps/ledger-live-desktop/src/mvvm/features/Perps/screens/PerpsDeposit/components/DepositAccountSelector.tsx

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,38 @@ type DepositAccountSelectorProps = Readonly<{
2222
onSelect: () => void;
2323
}>;
2424

25+
function DepositAccountDescription({
26+
accountName,
27+
counterValue,
28+
exceedsBalance,
29+
missingAccount,
30+
}: Pick<
31+
DepositAccountSelectorProps,
32+
"accountName" | "counterValue" | "exceedsBalance" | "missingAccount"
33+
>) {
34+
const { t } = useTranslation();
35+
36+
if (accountName === null) {
37+
return (
38+
<span className={cn(missingAccount && "text-error")}>
39+
{t("perpsDeposit.selectCurrencyNoAccount")}
40+
</span>
41+
);
42+
}
43+
44+
if (counterValue === null) return <span>{accountName}</span>;
45+
46+
return (
47+
<Trans
48+
i18nKey="perpsDeposit.selectCurrencyAccount"
49+
values={{ accountName, counterValue }}
50+
components={{
51+
balance: <span className={cn(exceedsBalance && "text-error")} />,
52+
}}
53+
/>
54+
);
55+
}
56+
2557
export function DepositAccountSelector({
2658
ticker,
2759
ledgerId,
@@ -46,19 +78,12 @@ export function DepositAccountSelector({
4678
{t("perpsDeposit.selectCurrencyTitle", { currencyTicker: ticker })}
4779
</ListItemTitle>
4880
<ListItemDescription>
49-
{accountName && counterValue ? (
50-
<Trans
51-
i18nKey="perpsDeposit.selectCurrencyAccount"
52-
values={{ accountName, counterValue }}
53-
components={{
54-
balance: <span className={cn(exceedsBalance && "text-error")} />,
55-
}}
56-
/>
57-
) : (
58-
<span className={cn(missingAccount && "text-error")}>
59-
{t("perpsDeposit.selectCurrencyDescription")}
60-
</span>
61-
)}
81+
<DepositAccountDescription
82+
accountName={accountName}
83+
counterValue={counterValue}
84+
exceedsBalance={exceedsBalance}
85+
missingAccount={missingAccount}
86+
/>
6287
</ListItemDescription>
6388
</ListItemContent>
6489
</ListItemLeading>

apps/ledger-live-desktop/static/i18n/en/app.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9817,7 +9817,7 @@
98179817
"inputSubText": "Swap and deposit via SwapKit",
98189818
"selectCurrencyTitle": "Deposit with {{currencyTicker}}",
98199819
"selectCurrencyAccount": "{{accountName}} · <balance>{{counterValue}}</balance>",
9820-
"selectCurrencyDescription": "No account",
9820+
"selectCurrencyNoAccount": "No account",
98219821
"review": "Review",
98229822
"formErrors": {
98239823
"amountExceedsBalance": "Insufficient balance",

0 commit comments

Comments
 (0)