refactor: normalize view models and share breadcrumbs and titles (WealthLedger/frontend#143) (#153)
Frontend verify / commits (push) Skipped
Frontend verify / security (push) Successful in 11s
Frontend verify / verify (push) Failing after 8m19s

This commit was merged in pull request #153.
This commit is contained in:
2026-11-04 21:14:29 +03:00
parent 2d070ce2b5
commit 2db39f25d9
30 changed files with 194 additions and 202 deletions
@@ -1,22 +1,22 @@
import type { FC } from "react";
import { useAccountsPageViewModel } from "./AccountsPage.vm";
import { useAccountsPageVm } from "./AccountsPage.vm";
import { AccountsPageEmpty } from "./components/AccountsPageEmpty.view";
import { AccountsPageError } from "./components/AccountsPageError.view";
import { AccountsPageLoaded } from "./components/AccountsPageLoaded.view";
import { AccountsPageLoading } from "./components/AccountsPageLoading.view";
const AccountsPage: FC = () => {
const viewModel = useAccountsPageViewModel();
if (viewModel.state === "loading") return <AccountsPageLoading />;
if (viewModel.state === "error") return <AccountsPageError {...viewModel} />;
if (viewModel.state === "empty") return <AccountsPageEmpty />;
const vm = useAccountsPageVm();
if (vm.state === "loading") return <AccountsPageLoading />;
if (vm.state === "error") return <AccountsPageError {...vm} />;
if (vm.state === "empty") return <AccountsPageEmpty />;
return (
<AccountsPageLoaded
accounts={viewModel.accounts}
meta={viewModel.meta}
readRetry={viewModel.readRetry}
accounts={vm.accounts}
meta={vm.meta}
readRetry={vm.readRetry}
/>
);
};
@@ -30,7 +30,7 @@ function isAccountsAccessFailure(code?: string) {
|| isApiErrorCode(code, ApiErrorCode.TbankNotConnected);
}
function useAccountsPageViewModel(): AccountsPageViewModel {
function useAccountsPageVm(): AccountsPageViewModel {
const accounts = useBrokerageAccounts();
useScreenSync({ screen: "accounts" }, [accounts]);
@@ -73,4 +73,4 @@ function useAccountsPageViewModel(): AccountsPageViewModel {
};
}
export { useAccountsPageViewModel };
export { useAccountsPageVm };