chore: finish frontend ESLint migration #18
Frontend security / security (push) Successful in 9s
Frontend verify / verify (push) Failing after 37m50s
Frontend security / security (pull_request) Successful in 9s
Frontend verify / verify (pull_request) Failing after 42m10s
Conventional commits / commits (pull_request) Successful in 29s
Frontend security / security (push) Successful in 9s
Frontend verify / verify (push) Failing after 37m50s
Frontend security / security (pull_request) Successful in 9s
Frontend verify / verify (pull_request) Failing after 42m10s
Conventional commits / commits (pull_request) Successful in 29s
Enable every plugin recommended preset and replace Biome with ESLint formatting. Preserve API contracts and JSX whitespace; verify source, tests, builds and tooling.
This commit is contained in:
@@ -3,24 +3,26 @@ import type {
|
||||
useBrokerageAccounts,
|
||||
} from "../api/useBrokerageAccounts";
|
||||
|
||||
type Money = NonNullable<
|
||||
BrokerageAccount["portfolioSummary"]
|
||||
>["totalsByCurrency"][number];
|
||||
const VISIBLE_CURRENCY_LIMIT = 2;
|
||||
|
||||
type BrokerageAccountCard = {
|
||||
account: BrokerageAccount;
|
||||
positionCounts: null | { bonds: number; stocks: number };
|
||||
source?: NonNullable<
|
||||
ReturnType<typeof useBrokerageAccounts>["meta"]
|
||||
>["dependencies"] extends (infer T)[] | undefined
|
||||
? T
|
||||
: never;
|
||||
account: BrokerageAccount;
|
||||
positionCounts: { stocks: number; bonds: number } | null;
|
||||
summary:
|
||||
| { state: "unavailable" }
|
||||
| { remainingCurrencyCount: number; state: "available"; totals: Money[] }
|
||||
| { state: "empty" }
|
||||
| { state: "available"; totals: Money[]; remainingCurrencyCount: number };
|
||||
| { state: "unavailable" };
|
||||
};
|
||||
|
||||
type Money = NonNullable<
|
||||
BrokerageAccount["portfolioSummary"]
|
||||
>["totalsByCurrency"][number];
|
||||
|
||||
function accountTypeKey(type: BrokerageAccount["type"]) {
|
||||
return `accounts.types.${type}` as const;
|
||||
}
|
||||
@@ -33,34 +35,34 @@ function brokerageAccountCards(
|
||||
): BrokerageAccountCard[] {
|
||||
return accounts.map((account) => {
|
||||
const source = dependencies.find(
|
||||
(item) =>
|
||||
item =>
|
||||
item.resourceKey === `portfolio/${encodeURIComponent(account.id)}`,
|
||||
);
|
||||
const summary = account.portfolioSummary;
|
||||
if (!summary)
|
||||
return {
|
||||
source,
|
||||
account,
|
||||
positionCounts: null,
|
||||
positionCounts: /* eslint-disable-line unicorn/no-null -- The existing formatter contract uses null for unavailable data. */ null,
|
||||
source,
|
||||
summary: { state: "unavailable" },
|
||||
};
|
||||
const positionCounts = {
|
||||
stocks: summary.stockPositionCount,
|
||||
bonds: summary.bondPositionCount,
|
||||
stocks: summary.stockPositionCount,
|
||||
};
|
||||
if (!summary.totalsByCurrency.length)
|
||||
return { source, account, positionCounts, summary: { state: "empty" } };
|
||||
if (summary.totalsByCurrency.length === 0)
|
||||
return { account, positionCounts, source, summary: { state: "empty" } };
|
||||
return {
|
||||
source,
|
||||
account,
|
||||
positionCounts,
|
||||
source,
|
||||
summary: {
|
||||
state: "available",
|
||||
totals: summary.totalsByCurrency.slice(0, 2),
|
||||
remainingCurrencyCount: Math.max(
|
||||
summary.totalsByCurrency.length - 2,
|
||||
summary.totalsByCurrency.length - VISIBLE_CURRENCY_LIMIT,
|
||||
0,
|
||||
),
|
||||
state: "available",
|
||||
totals: summary.totalsByCurrency.slice(0, VISIBLE_CURRENCY_LIMIT),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user