fix(design): correct the incident list footer range on empty and out-of-range pages

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 09:43:44 +08:00
co-authored by Claude Haiku 4.5
parent 582504c24b
commit 87f553321b
2 changed files with 18 additions and 3 deletions
+3 -3
View File
@@ -82,8 +82,8 @@ export function IncidentTable({ incidents, basePath, total, counts, params, site
const clearable = Boolean(params.q || params.status || params.type || params.siteId || params.truckId)
const pageCount = Math.max(1, Math.ceil(total / PAGE_SIZE))
const from = total === 0 ? 0 : (params.page - 1) * PAGE_SIZE + 1
const to = Math.min(total, from + incidents.length - 1)
const from = incidents.length === 0 ? 0 : (params.page - 1) * PAGE_SIZE + 1
const to = incidents.length === 0 ? 0 : from + incidents.length - 1
const toolbar = (
<>
@@ -161,7 +161,7 @@ export function IncidentTable({ incidents, basePath, total, counts, params, site
const next = nextSort({ key: params.sort, dir: params.dir }, key as SortKey)
update({ sort: next.key, dir: next.dir })
}}
footer={{ from, to, total, page: params.page, pageCount, onPage: p => update({ page: String(p) }) }}
footer={total > 0 ? { from, to, total, page: params.page, pageCount, onPage: p => update({ page: String(p) }) } : undefined}
empty={{
title: 'No incidents found',
action: <Button onClick={() => router.push('/report')}>Report incident</Button>,