28 lines
706 B
TypeScript
28 lines
706 B
TypeScript
import {
|
|
apiQueryClient,
|
|
type paths,
|
|
useAuthenticatedQuery,
|
|
} from "@/shared/api";
|
|
|
|
type EventsEndpoint =
|
|
paths["/api/v1/brokerage-accounts/{accountId}/events"]["get"];
|
|
type BrokerageEvent =
|
|
EventsEndpoint["responses"][200]["content"]["application/json"]["events"][number];
|
|
|
|
function useBrokerageEvents(
|
|
accountId: string | undefined,
|
|
query: EventsEndpoint["parameters"]["query"] = {},
|
|
) {
|
|
return useAuthenticatedQuery({
|
|
...apiQueryClient.queryOptions(
|
|
"get",
|
|
"/api/v1/brokerage-accounts/{accountId}/events",
|
|
{ params: { path: { accountId: accountId ?? "" }, query } },
|
|
),
|
|
enabled: Boolean(accountId),
|
|
staleTime: 30_000,
|
|
});
|
|
}
|
|
|
|
export { type BrokerageEvent, useBrokerageEvents };
|