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
@@ -26,7 +26,7 @@ import { resource } from "@/test/resource";
import { server } from "@/test/server";
import { AccountEventsPage } from "./AccountEventsPage";
import { useAccountEventsPageViewModel } from "./AccountEventsPage.vm";
import { useAccountEventsPageVm } from "./AccountEventsPage.vm";
const Navigation: FC = () => {
const location = useLocation();
@@ -100,7 +100,7 @@ describe("Upcoming event date filters", () => {
);
const queryClient = createTestQueryClient();
const { result } = renderHook(() => useAccountEventsPageViewModel(), {
const { result } = renderHook(() => useAccountEventsPageVm(), {
wrapper: ({ children }) => (
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={["?from=2099-02-01"]}>
@@ -146,7 +146,7 @@ describe("Upcoming event date filters", () => {
const queryClient = createTestQueryClient();
const { result } = renderHook(
() => useAccountEventsPageViewModel(),
() => useAccountEventsPageVm(),
{
wrapper: ({ children }) => (
<QueryClientProvider client={queryClient}>
@@ -361,7 +361,7 @@ it("retains the previous complete forecast when its source refresh fails", async
);
const queryClient = createTestQueryClient();
const { result } = renderHook(() => useAccountEventsPageViewModel(), {
const { result } = renderHook(() => useAccountEventsPageVm(), {
wrapper: ({ children }) => (
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={["/accounts/all/events"]}>
@@ -1,17 +1,17 @@
import type { FC } from "react";
import { useAccountEventsPageViewModel } from "./AccountEventsPage.vm";
import { useAccountEventsPageVm } from "./AccountEventsPage.vm";
import { AccountEventsPageError } from "./components/AccountEventsPageError.view";
import { AccountEventsPageLoaded } from "./components/AccountEventsPageLoaded.view";
import { AccountEventsPageLoading } from "./components/AccountEventsPageLoading.view";
const AccountEventsPage: FC = () => {
const viewModel = useAccountEventsPageViewModel();
if (viewModel.state === "loading") return <AccountEventsPageLoading />;
const vm = useAccountEventsPageVm();
if (vm.state === "loading") return <AccountEventsPageLoading />;
return viewModel.state === "error"
? <AccountEventsPageError {...viewModel} />
: <AccountEventsPageLoaded {...viewModel} />;
return vm.state === "error"
? <AccountEventsPageError {...vm} />
: <AccountEventsPageLoaded {...vm} />;
};
export { AccountEventsPage };
@@ -39,7 +39,7 @@ type AccountEventsPageViewModel
}
| { state: "loading" };
function useAccountEventsPageViewModel(): AccountEventsPageViewModel {
function useAccountEventsPageVm(): AccountEventsPageViewModel {
const { accountId = "" } = useParams();
const {
@@ -136,4 +136,4 @@ function useAccountEventsPageViewModel(): AccountEventsPageViewModel {
};
}
export { type AccountEventsPageViewModel, useAccountEventsPageViewModel };
export { type AccountEventsPageViewModel, useAccountEventsPageVm };