51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { apiQueryClient, type paths, useResourceQuery } from "@/shared/api";
|
|
|
|
type IncomeAnalytics = NonNullable<
|
|
paths["/api/v1/brokerage-accounts/{accountId}/income-analytics"]["get"]["responses"][200]["content"]["application/json"]["data"]
|
|
>;
|
|
|
|
type IncomeSummary = NonNullable<
|
|
paths["/api/v1/brokerage-accounts/{accountId}/income-summary"]["get"]["responses"][200]["content"]["application/json"]["data"]
|
|
>;
|
|
|
|
function useIncomeAnalytics(
|
|
accountId: string | undefined,
|
|
period: { from: string; to: string },
|
|
) {
|
|
return useResourceQuery({
|
|
meta: { accessGroup: "brokerage" },
|
|
...apiQueryClient.queryOptions(
|
|
"get",
|
|
"/api/v1/brokerage-accounts/{accountId}/income-analytics",
|
|
{
|
|
params: {
|
|
path: { accountId: accountId ?? "" },
|
|
query: period,
|
|
},
|
|
},
|
|
),
|
|
enabled: Boolean(accountId),
|
|
staleTime: 30_000,
|
|
});
|
|
}
|
|
|
|
function useIncomeSummary(accountId?: string) {
|
|
return useResourceQuery({
|
|
meta: { accessGroup: "brokerage" },
|
|
...apiQueryClient.queryOptions(
|
|
"get",
|
|
"/api/v1/brokerage-accounts/{accountId}/income-summary",
|
|
{ params: { path: { accountId: accountId ?? "" } } },
|
|
),
|
|
enabled: Boolean(accountId),
|
|
staleTime: 30_000,
|
|
});
|
|
}
|
|
|
|
export {
|
|
type IncomeAnalytics,
|
|
type IncomeSummary,
|
|
useIncomeAnalytics,
|
|
useIncomeSummary,
|
|
};
|