refactor: refactor foundation

This commit is contained in:
2026-08-14 09:43:19 +03:00
parent 2e32d226d3
commit da585b157a
54 changed files with 4822 additions and 535 deletions
+9 -15
View File
@@ -1,11 +1,11 @@
import { useQuery } from "@tanstack/react-query";
import { apiClient } from "../../../shared/api";
import type { paths } from "../../../shared/api/generated/schema";
import { apiQueryClient } from "@/shared/api";
import type { paths } from "@/shared/api/generated/schema";
export const portfolioQueryKey = (accountId: string) =>
const portfolioQueryKey = (accountId: string) =>
["portfolio", accountId] as const;
export const portfolioQueryPolicy = {
const portfolioQueryPolicy = {
staleTime: 30_000,
retry: false,
} as const;
@@ -21,16 +21,10 @@ export function usePortfolio(
queryKey: portfolioQueryKey(accountId ?? ""),
enabled: Boolean(accountId && accessToken),
...portfolioQueryPolicy,
queryFn: async () => {
const { data, error } = await apiClient.GET(
"/api/v1/brokerage-accounts/{accountId}/portfolio",
{
params: { path: { accountId: accountId ?? "" } },
headers: { Authorization: `Bearer ${accessToken}` },
},
);
if (error) throw error;
return data as Portfolio;
},
...apiQueryClient.queryOptions(
"get",
"/api/v1/brokerage-accounts/{accountId}/portfolio",
{ params: { path: { accountId: accountId ?? "" } } },
),
});
}