From fadb2c0a80b76b62ac7a3da0dc7225708ec45573 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Sivakumar Date: Sun, 19 Jul 2026 19:41:39 +0530 Subject: [PATCH] fix: make Verification Management pagination actually work The page/next/prev controls were static markup with no onClick handlers, and the "Showing X-Y of Z" label always rendered the same number for X, Y, and Z (all displayRows().length) - pagination never did anything, all fetched rows rendered on one page. Wires it to a real page signal with working prev/next/page-number buttons, resets to page 1 when filters change, and fixes the range label. Co-Authored-By: Claude Sonnet 5 --- src/routes/admin/verification/index.tsx | 62 +++++++++++++++++++++---- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/src/routes/admin/verification/index.tsx b/src/routes/admin/verification/index.tsx index f8609ec..9300a6f 100644 --- a/src/routes/admin/verification/index.tsx +++ b/src/routes/admin/verification/index.tsx @@ -1,5 +1,7 @@ import { A } from '@solidjs/router'; -import { For, Show, createMemo, createSignal, onMount } from 'solid-js'; +import { For, Show, createEffect, createMemo, createSignal, on, onMount } from 'solid-js'; + +const PAGE_SIZE = 20; type VerificationStatus = 'PENDING' | 'UNDER_REVIEW' | 'DOCUMENTS_REQUESTED' | 'REVISION_REQUESTED' | 'APPROVED' | 'REJECTED'; type VerificationPriority = 'HIGH' | 'MEDIUM' | 'LOW'; @@ -154,6 +156,7 @@ export default function VerificationManagementPage() { const [docSelection, setDocSelection] = createSignal>({}); const [requestNote, setRequestNote] = createSignal(''); const [actionMessage, setActionMessage] = createSignal(''); + const [page, setPage] = createSignal(1); const load = async () => { try { @@ -256,8 +259,33 @@ export default function VerificationManagementPage() { return next; }); + const totalPages = createMemo(() => Math.max(1, Math.ceil(filteredRows().length / PAGE_SIZE))); + + // Reset to page 1 whenever the underlying result set changes shape (search, + // status/category filters, sort) - otherwise a filter change can strand the + // user on a page number that no longer has any rows. + createEffect(on([search, statusFilter, categoryTab, sortBy], () => { + setPage(1); + }, { defer: true })); + + createEffect(() => { + if (page() > totalPages()) setPage(totalPages()); + }); + const displayRows = createMemo(() => { - return filteredRows(); + const start = (page() - 1) * PAGE_SIZE; + return filteredRows().slice(start, start + PAGE_SIZE); + }); + + const pageNumbers = createMemo(() => { + const total = totalPages(); + const current = page(); + const window = 2; + const nums: number[] = []; + for (let n = Math.max(1, current - window); n <= Math.min(total, current + window); n++) { + nums.push(n); + } + return nums; }); const metrics = createMemo(() => { @@ -762,14 +790,32 @@ export default function VerificationManagementPage() { 0}>

- Showing 1–{displayRows().length} of {displayRows().length} verifications + Showing {(page() - 1) * PAGE_SIZE + 1}–{(page() - 1) * PAGE_SIZE + displayRows().length} of {filteredRows().length} verifications

- - - - - + + + {(n) => ( + + )} + +