refactor: centralize frontend auth query gating
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { apiQueryClient } from "@/shared/api";
|
||||
import { apiQueryClient, useAuthenticatedQuery } from "@/shared/api";
|
||||
import type { paths } from "@/shared/api/generated/schema";
|
||||
|
||||
const brokerageAccountsQueryOptions = () =>
|
||||
@@ -11,10 +10,9 @@ export const brokerageAccountsQueryKey =
|
||||
export type BrokerageAccount =
|
||||
paths["/api/v1/brokerage-accounts"]["get"]["responses"][200]["content"]["application/json"][number];
|
||||
|
||||
export function useBrokerageAccounts(accessToken: string | null) {
|
||||
return useQuery({
|
||||
export function useBrokerageAccounts() {
|
||||
return useAuthenticatedQuery({
|
||||
...brokerageAccountsQueryOptions(),
|
||||
enabled: Boolean(accessToken),
|
||||
staleTime: 60_000,
|
||||
retry: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user