refactor!: support RUB only (WealthLedger/main#55) (#168)
This commit was merged in pull request #168.
This commit is contained in:
@@ -4,8 +4,6 @@ import type {
|
||||
BrokerageAccount,
|
||||
} from "../api/useBrokerageAccounts";
|
||||
|
||||
const VISIBLE_CURRENCY_LIMIT = 2;
|
||||
|
||||
type BrokerageAccountCard = {
|
||||
account: BrokerageAccount;
|
||||
positionCounts: null | PositionCounts;
|
||||
@@ -13,18 +11,13 @@ type BrokerageAccountCard = {
|
||||
summary:
|
||||
| {
|
||||
portfolio: NonNullable<BrokerageAccount["portfolioSummary"]>;
|
||||
remainingCurrencyCount: number;
|
||||
state: "available";
|
||||
totals: Money[];
|
||||
totals: NonNullable<BrokerageAccount["portfolioSummary"]>["totals"];
|
||||
}
|
||||
| { state: "empty" }
|
||||
| { state: "unavailable" };
|
||||
};
|
||||
|
||||
type Money = NonNullable<
|
||||
BrokerageAccount["portfolioSummary"]
|
||||
>["totalsByCurrency"][number];
|
||||
|
||||
type PositionCounts = { bonds: number; stocks: number; total: number };
|
||||
|
||||
function accountTypeKey(type: BrokerageAccount["type"]) {
|
||||
@@ -57,7 +50,7 @@ function brokerageAccountCards(
|
||||
total: summary.totalPositionCount,
|
||||
};
|
||||
|
||||
if (summary.totalsByCurrency.length === 0)
|
||||
if (Number(summary.totals.value) === 0)
|
||||
return { account, positionCounts, source, summary: { state: "empty" } };
|
||||
|
||||
return {
|
||||
@@ -66,12 +59,8 @@ function brokerageAccountCards(
|
||||
source,
|
||||
summary: {
|
||||
portfolio: summary,
|
||||
remainingCurrencyCount: Math.max(
|
||||
summary.totalsByCurrency.length - VISIBLE_CURRENCY_LIMIT,
|
||||
0,
|
||||
),
|
||||
state: "available",
|
||||
totals: summary.totalsByCurrency.slice(0, VISIBLE_CURRENCY_LIMIT),
|
||||
totals: summary.totals,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user