fix(account): show source metadata on empty account and income (WealthLedger/frontend#55) (#133)
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 10s
Frontend verify / verify (push) Failing after 6m34s

This commit was merged in pull request #133.
This commit is contained in:
2026-11-03 06:44:13 +03:00
parent 71fbe7774d
commit 9619dc9791
12 changed files with 131 additions and 33 deletions
@@ -16,7 +16,7 @@ import {
import { useIncomeSummary } from "@/entities/income";
import { usePortfolio } from "@/entities/portfolio";
import { useScreenSync } from "@/features/tbank-connection";
import { ApiErrorCode, apiErrorCode, isApiErrorCode } from "@/shared/api";
import { apiErrorCode, isBrokerageAccessLoss } from "@/shared/api";
import { useInitialAvailability } from "@/shared/lib";
import {
@@ -47,6 +47,7 @@ type AccountPageContent = {
partial?: boolean;
recentEvents: AccountPageRecentEvents;
recentOperations: AccountPageRecentOperations;
source?: InvestmentResourceMeta;
};
type AccountPageEmptyViewModel = AccountPageContent & {
@@ -62,7 +63,6 @@ type AccountPageLoadedViewModel = AccountPageContent & {
portfolio: Portfolio;
positionSections: AccountPagePositionSection[];
slice: Slice;
source?: InvestmentResourceMeta;
state: "loaded";
tab: string;
unrealizedReturns: Portfolio["totalsByCurrency"];
@@ -74,12 +74,6 @@ type AccountPageViewModel
| { code?: string; state: "error" }
| { state: "loading" };
function isPortfolioAccessFailure(code?: string) {
return isApiErrorCode(code, ApiErrorCode.InvalidTbankToken)
|| isApiErrorCode(code, ApiErrorCode.NotFound)
|| isApiErrorCode(code, ApiErrorCode.TbankNotConnected);
}
function useAccountPageViewModel(): AccountPageViewModel {
const { accountId } = useParams();
const { t } = useTranslation();
@@ -119,7 +113,7 @@ function useAccountPageViewModel(): AccountPageViewModel {
]);
const code = apiErrorCode(portfolio.error);
const isAccessFailure = isPortfolioAccessFailure(code);
const isAccessFailure = isBrokerageAccessLoss(code);
const availability = useInitialAvailability({
hasContent: !!portfolio.data,
@@ -152,6 +146,7 @@ function useAccountPageViewModel(): AccountPageViewModel {
incomeSummary,
recentEvents,
recentOperations,
source: portfolio.meta,
state: "empty" as const,
};