From 9b8d9c7391f7a6b4a66fdbbd722ea940be319a05 Mon Sep 17 00:00:00 2001 From: kongkx Date: Fri, 11 Sep 2026 17:48:59 +0800 Subject: [PATCH] fix(resume): paginate batch details --- src/features/resume/batch-detail-sheet.tsx | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/features/resume/batch-detail-sheet.tsx b/src/features/resume/batch-detail-sheet.tsx index 6c3d112..a86ce7b 100644 --- a/src/features/resume/batch-detail-sheet.tsx +++ b/src/features/resume/batch-detail-sheet.tsx @@ -1,4 +1,4 @@ -import { useQuery, useQueryClient } from '@tanstack/react-query' +import { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query' import { useState } from 'react' import { toast } from 'sonner' import type { ResumeImportItem, ResumeImportOutcome } from '@/api/types' @@ -57,13 +57,16 @@ export function ResumeImportBatchDetailSheet({ batchId, onOpenChange }: Props) { const batch = batchQuery.data?.data - const itemsQuery = useQuery({ + const itemsQuery = useInfiniteQuery({ queryKey: ['resume-import-items', batchId, outcome], - queryFn: () => + queryFn: ({ pageParam }) => fetchImportBatchItems(batchId as string, { + page: pageParam, page_size: 100, ...(outcome === 'all' ? {} : { outcome }), }), + initialPageParam: 1, + getNextPageParam: (lastPage) => lastPage.pagination.next_page ?? undefined, enabled: batchId !== null, // Follow the batch: keep refreshing the report while rows are still moving. refetchInterval: batch && (batch.status === 'completed' || batch.status === 'failed') @@ -71,7 +74,7 @@ export function ResumeImportBatchDetailSheet({ batchId, onOpenChange }: Props) { : POLL_INTERVAL, }) - const items = itemsQuery.data?.data ?? [] + const items = itemsQuery.data?.pages.flatMap((page) => page.data) ?? [] const refresh = () => { void batchQuery.refetch() void itemsQuery.refetch() @@ -255,6 +258,15 @@ export function ResumeImportBatchDetailSheet({ batchId, onOpenChange }: Props) { )} ))} + {itemsQuery.hasNextPage && ( + + )} )}