Files
frontend/src/entities/brokerage-event/api/useBrokerageEvents.ts
T
ksv741 4e5f564fa1 feat: show persisted investment data and sync state
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.
2026-09-26 21:22:49 +03:00

26 lines
780 B
TypeScript

import { apiQueryClient, type paths, useResourceQuery } from "@/shared/api";
type EventsEndpoint =
paths["/api/v1/brokerage-accounts/{accountId}/events"]["get"];
type BrokerageEvent = NonNullable<
EventsEndpoint["responses"][200]["content"]["application/json"]["data"]
>["events"][number];
function useBrokerageEvents(
accountId: string | undefined,
query: Omit<NonNullable<EventsEndpoint["parameters"]["query"]>, "sync"> = {},
) {
return useResourceQuery({
meta: { accessGroup: "brokerage" },
...apiQueryClient.queryOptions(
"get",
"/api/v1/brokerage-accounts/{accountId}/events",
{ params: { path: { accountId: accountId ?? "" }, query } },
),
enabled: Boolean(accountId),
staleTime: 30_000,
});
}
export { type BrokerageEvent, useBrokerageEvents };