refactor!: support RUB only (WealthLedger/main#55) (#168)
This commit was merged in pull request #168.
This commit is contained in:
@@ -21,7 +21,6 @@ import { useInitialAvailability } from "@/shared/lib";
|
||||
|
||||
import {
|
||||
type Concentration,
|
||||
concentrationCurrencies,
|
||||
type ConcentrationLabels,
|
||||
type Slice,
|
||||
toConcentration,
|
||||
@@ -57,8 +56,6 @@ type AccountPageEmptyViewModel = AccountPageContent & {
|
||||
|
||||
type AccountPageLoadedViewModel = AccountPageContent & {
|
||||
concentration: Concentration | null;
|
||||
currency: null | string;
|
||||
onCurrencyChange: (currency: null | string) => void;
|
||||
onSliceChange: (slice: Slice) => void;
|
||||
onTabChange: (tab: null | string) => void;
|
||||
portfolio: Portfolio;
|
||||
@@ -66,7 +63,9 @@ type AccountPageLoadedViewModel = AccountPageContent & {
|
||||
slice: Slice;
|
||||
state: "loaded";
|
||||
tab: string;
|
||||
unrealizedReturns: Portfolio["totalsByCurrency"];
|
||||
unrealizedReturns:
|
||||
| null
|
||||
| { currency: string; value: string };
|
||||
};
|
||||
|
||||
type AccountPageReadRetry = ReturnType<typeof readRetry>;
|
||||
@@ -83,15 +82,14 @@ function useAccountPageVm(): AccountPageViewModel {
|
||||
|
||||
const [selection, setSelection] = useState<{
|
||||
accountId?: string;
|
||||
currency: null | string;
|
||||
slice: Slice;
|
||||
tab: string;
|
||||
}>({ accountId, currency: null, slice: "stocks", tab: "positions" });
|
||||
}>({ accountId, slice: "stocks", tab: "positions" });
|
||||
|
||||
const current = selection.accountId === accountId
|
||||
? selection
|
||||
: {
|
||||
accountId, currency: null, slice: "stocks" as const, tab: "positions",
|
||||
accountId, slice: "stocks" as const, tab: "positions",
|
||||
};
|
||||
|
||||
const updateSelection = (change: Partial<typeof selection>) =>
|
||||
@@ -144,7 +142,7 @@ function useAccountPageVm(): AccountPageViewModel {
|
||||
if (
|
||||
portfolio.meta?.availability === "available"
|
||||
&& portfolio.data.positions.length === 0
|
||||
&& portfolio.data.cashBalances.length === 0
|
||||
&& Number(portfolio.data.cash.value) === 0
|
||||
)
|
||||
return {
|
||||
account,
|
||||
@@ -158,11 +156,6 @@ function useAccountPageVm(): AccountPageViewModel {
|
||||
};
|
||||
|
||||
const isPartial = portfolio.meta?.completeness === "incomplete";
|
||||
const currencies = concentrationCurrencies(portfolio.data);
|
||||
|
||||
const currency = current.currency && currencies.includes(current.currency)
|
||||
? current.currency
|
||||
: currencies[0] ?? null;
|
||||
|
||||
const labels: ConcentrationLabels = {
|
||||
missingIssuer: t("portfolio.concentration.missingIssuer"),
|
||||
@@ -173,16 +166,14 @@ function useAccountPageVm(): AccountPageViewModel {
|
||||
|
||||
const concentration = accountId !== "all"
|
||||
&& current.tab === "concentration"
|
||||
? toConcentration(portfolio.data, current.slice, currency, labels)
|
||||
? toConcentration(portfolio.data, current.slice, labels)
|
||||
: null;
|
||||
|
||||
return {
|
||||
account,
|
||||
accountId,
|
||||
concentration,
|
||||
currency,
|
||||
incomeSummary,
|
||||
onCurrencyChange: value => updateSelection({ currency: value }),
|
||||
onSliceChange: slice => updateSelection({ slice }),
|
||||
onTabChange: tab => updateSelection({ tab: tab ?? "positions" }),
|
||||
partial: isPartial,
|
||||
|
||||
Reference in New Issue
Block a user