[Issue]: Paginate PO history #104
Labels
No labels
bug
claude-failed
claude-pr
claude-queue
claude-working
epic
feature
interactive
portal
triaged
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: shad0w/pelagia-portal#104
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Raised by
Kaushal Pal Singh (kps@pelagiamarine.com, MANAGER) — via portal Report Issue button
Description
Paginate /history with items per page dropdown
Priority
P2 — Medium
Context
/historyClaude triage
Triage — Issue #104: Paginate PO history
Type: Feature (enhancement to existing
/historybehaviour)Priority: P2 — Medium
Page:
/historyInterpretation
The PO History page (
/history) currently fetches the most recent 200 POs ina single query (
take: 200,orderBy createdAt desc) and renders them in one flattable, with a notice ("Showing first 200 results — refine filters to narrow results")
when the cap is hit. There is no way to page past the first 200, and no control over
how many rows show at once.
The request is to add pagination to this table plus an items-per-page dropdown
(e.g. 25 / 50 / 100), preserving the existing filters across page changes.
Action items
Server component —
App/app/(portal)/history/page.tsxpageandperPagefromsearchParams(add to thePropstype). Defaultpage=1; defaultperPageto a sensible value (e.g. 25) and clamp to the allowedset (25/50/100) to avoid arbitrary/abusive page sizes.
take: 200withskip: (page-1)*perPage+take: perPage.db.purchaseOrder.count({ where })(run in the existingPromise.all) toget total rows → compute total pages.
countis already an established pattern(e.g.
dashboard/page.tsx).(Prev/Next + page indicator, "Showing X–Y of N"). Keep the Export PDF/CSV
links exporting the full filtered set (they build their own params and hit
/api/reports/export— must remain unpaginated).page(e.g. page beyond last → clamp or show empty).Client filter component —
App/app/(portal)/history/history-filters.tsx<select>(25/50/100). On change, push to/historywiththe updated
perPageand resetpageto 1.apply()/clear()preserve or resetpage/perPageconsistently(changing a filter should reset to page 1).
or in the pagination footer — either is fine; the filter bar keeps it with the other
controls and is the lower-risk reuse of the existing
useRouter/useSearchParamswiring.
(Optional) extract a small pagination helper/component under
components/ui/ifit reads cleanly — but the codebase has no existing pagination component, so an
inline footer in
page.tsxis acceptable and lower-risk for a single page.Files / areas involved
App/app/(portal)/history/page.tsx(query: skip/take + count; pagination footer)App/app/(portal)/history/history-filters.tsx(per-page dropdown; page reset on filter change)Open questions (non-blocking — sensible defaults available)
perPageoffer an "All" option? Recommend no, to preserve the originalintent of capping large result sets; if desired it can map back to the old 200 cap.
?page=&perPage=) to matchthe existing filter pattern (shareable/back-button friendly) —
history-filters.tsxalready round-trips all filters through the query string.
Verifiability
pnpm type-checkandpnpm lintcover the type/query changes.external system. The staging DB (
pelagia_test) holds prod-like volume so paging isexercisable, though no automated history test exists today (could add a light unit test
for a clamp/
perPagehelper if extracted).Routing rationale: Localized two-file enhancement (server component query + client filter control) with a clear acceptance, no DB/auth/payments/external dependency, verifiable by type-check + lint and diff review → claude-queue.
Routing:
claude-queue| Type:feature[Claude] Started working on this issue on branch
claude/issue-104.[Claude] Opened PR #105 with a proposed fix. Review and merge it, then create a release tag to deploy.