Files
frontend/src/entities/portfolio/api/usePortfolio.ts
T
ksv741 c97f62bd98 refactor: align frontend ownership boundaries
Close audit gaps across API drift, query policy, UI, and tests.
2026-09-06 18:20:05 +03:00

31 lines
768 B
TypeScript

import {
apiQueryClient,
type paths,
useAuthenticatedQuery,
} from "@/shared/api";
const portfolioQueryPolicy = {
staleTime: 30_000,
} as const;
type Portfolio =
paths["/api/v1/brokerage-accounts/{accountId}/portfolio"]["get"]["responses"][200]["content"]["application/json"];
function portfolioQueryOptions(accountId: string | undefined) {
return apiQueryClient.queryOptions(
"get",
"/api/v1/brokerage-accounts/{accountId}/portfolio",
{ params: { path: { accountId: accountId ?? "" } } },
);
}
function usePortfolio(accountId: string | undefined) {
return useAuthenticatedQuery({
...portfolioQueryOptions(accountId),
enabled: Boolean(accountId),
...portfolioQueryPolicy,
});
}
export { type Portfolio, portfolioQueryOptions, usePortfolio };