Consume the provided resource-envelope API snapshot. Preserve financial snapshots during refresh, observe synchronization without importing, and fence late responses across account and connection changes.
25 lines
670 B
TypeScript
25 lines
670 B
TypeScript
import { apiQueryClient, type paths, useResourceQuery } from "@/shared/api";
|
|
|
|
const brokerageAccountsQueryOptions = () =>
|
|
apiQueryClient.queryOptions("get", "/api/v1/brokerage-accounts");
|
|
|
|
const brokerageAccountsQueryKey = brokerageAccountsQueryOptions().queryKey;
|
|
|
|
type BrokerageAccount = NonNullable<
|
|
paths["/api/v1/brokerage-accounts"]["get"]["responses"][200]["content"]["application/json"]["data"]
|
|
>[number];
|
|
|
|
function useBrokerageAccounts() {
|
|
return useResourceQuery({
|
|
meta: { accessGroup: "brokerage" },
|
|
...brokerageAccountsQueryOptions(),
|
|
staleTime: 60_000,
|
|
});
|
|
}
|
|
|
|
export {
|
|
type BrokerageAccount,
|
|
brokerageAccountsQueryKey,
|
|
useBrokerageAccounts,
|
|
};
|