All checks were successful
- Add type query param to GET /accounts/:accountId/positions endpoint - Backend filters T-Bank portfolio positions by instrument type before pagination - Each instrument type (share, bond, etf, fund) has its own frontend table with independent cursor-based pagination and skeleton loading - Groups with no positions are automatically hidden - Cache key includes type for correct per-type caching - Remove centralized positions pagination state from BrokerAccountDetailPage - 94 backend tests / 112 frontend tests pass
19 lines
646 B
TypeScript
19 lines
646 B
TypeScript
import { keepPreviousData, useQuery } from '@tanstack/react-query';
|
|
import { getBrokerPositions } from '../api/broker';
|
|
import type { BrokerPositionsPage } from '../api/responses';
|
|
|
|
export function useBrokerPositions(
|
|
accountId: string | undefined,
|
|
query: { cursor?: string; limit?: number; type?: string } = {},
|
|
) {
|
|
return useQuery<BrokerPositionsPage>({
|
|
queryKey: ['broker', 'positions', accountId, query],
|
|
enabled: Boolean(accountId),
|
|
queryFn: async () => (await getBrokerPositions(accountId!, query)).data,
|
|
staleTime: 60_000,
|
|
retry: 2,
|
|
placeholderData: keepPreviousData,
|
|
refetchOnWindowFocus: false,
|
|
});
|
|
}
|