fix: stabilize frontend query cache contracts

This commit is contained in:
2026-08-23 15:20:08 +03:00
parent b285719c1b
commit 1250581ee3
12 changed files with 151 additions and 35 deletions
+2 -6
View File
@@ -2,9 +2,6 @@ import { useQuery } from "@tanstack/react-query";
import { apiQueryClient } from "@/shared/api";
import type { paths } from "@/shared/api/generated/schema";
const portfolioQueryKey = (accountId: string) =>
["portfolio", accountId] as const;
const portfolioQueryPolicy = {
staleTime: 30_000,
retry: false,
@@ -18,13 +15,12 @@ export function usePortfolio(
accessToken: string | null,
) {
return useQuery({
queryKey: portfolioQueryKey(accountId ?? ""),
enabled: Boolean(accountId && accessToken),
...portfolioQueryPolicy,
...apiQueryClient.queryOptions(
"get",
"/api/v1/brokerage-accounts/{accountId}/portfolio",
{ params: { path: { accountId: accountId ?? "" } } },
),
enabled: Boolean(accountId && accessToken),
...portfolioQueryPolicy,
});
}