feat: add brocker account list
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { apiClient } from "../../../shared/api";
|
||||
import type { paths } from "../../../shared/api/generated/schema";
|
||||
|
||||
export const brokerageAccountsQueryKey = ["brokerage-accounts"] as const;
|
||||
|
||||
export type BrokerageAccount =
|
||||
paths["/api/v1/brokerage-accounts"]["get"]["responses"][200]["content"]["application/json"][number];
|
||||
|
||||
export function useBrokerageAccounts(accessToken: string | null) {
|
||||
return useQuery({
|
||||
queryKey: brokerageAccountsQueryKey,
|
||||
enabled: Boolean(accessToken),
|
||||
staleTime: 60_000,
|
||||
retry: false,
|
||||
queryFn: async () => {
|
||||
const { data, error } = await apiClient.GET(
|
||||
"/api/v1/brokerage-accounts",
|
||||
{
|
||||
headers: { Authorization: `Bearer ${accessToken}` },
|
||||
},
|
||||
);
|
||||
if (error) throw error;
|
||||
return data as BrokerageAccount[];
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user