refactor: align frontend ownership boundaries
Close audit gaps across API drift, query policy, UI, and tests.
This commit is contained in:
@@ -1,24 +1,30 @@
|
||||
import { apiQueryClient, useAuthenticatedQuery } from "@/shared/api";
|
||||
import type { paths } from "@/shared/api/generated/schema";
|
||||
import {
|
||||
apiQueryClient,
|
||||
type paths,
|
||||
useAuthenticatedQuery,
|
||||
} from "@/shared/api";
|
||||
|
||||
const portfolioQueryPolicy = {
|
||||
staleTime: 30_000,
|
||||
retry: false,
|
||||
} 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({
|
||||
...apiQueryClient.queryOptions(
|
||||
"get",
|
||||
"/api/v1/brokerage-accounts/{accountId}/portfolio",
|
||||
{ params: { path: { accountId: accountId ?? "" } } },
|
||||
),
|
||||
...portfolioQueryOptions(accountId),
|
||||
enabled: Boolean(accountId),
|
||||
...portfolioQueryPolicy,
|
||||
});
|
||||
}
|
||||
|
||||
export { type Portfolio, usePortfolio };
|
||||
export { type Portfolio, portfolioQueryOptions, usePortfolio };
|
||||
|
||||
Reference in New Issue
Block a user