NWP-101: add export options - #166
Open
saumyasingh34335 wants to merge 1 commit into
Open
Conversation
Ops can now choose export columns and scope from the payments Export button instead of always getting every column for the current filter. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
Closes NWP-101
What changed
Ops can now choose which columns are exported and whether the export covers the current filter or all payments, instead of always getting a fixed 10-column file for the current filter.
GET /api/payments/exportnow readscolumns(comma-separated) andscope(current|all) from the query string; both are validated server-side against the existingEXPORT_COLUMNSallowlist (parseExportColumnsinsrc/lib/csv.ts) rather than trusted directly.scope=allreuses the same query builder (filterPayments/sortPayments) with the filtering fields cleared, so there is still one filtering path, not a second one. The filename now reflects scope and status, e.g.payments-disputed-2026-08-13.csvorpayments-all-2026-08-13.csv. The Export button on/paymentsnow opens an options dialog (src/app/payments/export-dialog.tsx) with column checkboxes (last4unchecked by default), a current-filter/all-payments scope choice showing the row count for each (read from the existingGET /api/paymentstotal), and a Download control that's disabled when no columns are selected.How I verified it
npm testpassesnpm test:npx tsc --noEmitandnpm run lintboth clean.Against the running dev server,
curl:columns=id,amount&scope=all→ 200,content-disposition: attachment; filename="payments-all-2026-09-10.csv"status=disputed&columns=id,last4→ 200,content-disposition: attachment; filename="payments-disputed-2026-09-10.csv"columns=(empty selection) → 400 with{"error":"Select at least one column to export."}I did not personally click through the dialog in a browser — I have no browser-automation tool in this environment, so I'm leaving that box unchecked rather than claiming it. I opened
http://localhost:3000/paymentsfor the user to look at, but haven't gotten confirmation back on how the dialog renders or behaves interactively.Acceptance criteria
toCsvalready calledformatMoneyat the edge), with currency in its own column.Bugs fixed along the way
None found outside the ticket's scope.
Notes for the reviewer
GET /api/payments(once for the current filter, once with no filters) and reads the existingtotalfield, per the ticket's instruction to reuse the query builder rather than add a new path.scope=all→all;scope=currentwith a specific status → that status;scope=currentwithstatus=all(or another filter like merchant/search active) →filtered.Drawer(Radix Dialog) primitive already in the codebase rather than introducing a new modal component.🤖 Generated with Claude Code