Repository navigation
Conversation
The payments Export button now opens a dialog where ops choose the columns
(card last four off by default) and the scope (current filter or all
payments), with the row count shown before download.
- lib/csv: default columns without last4, allowlisted column and scope
parsing, scope label in the filename (payments-disputed-2026-08-13.csv)
- export route: validates columns and scope before running the query
builder, returns 400 { error } on bad input, never paginates
- components/Dialog: Radix dialog primitive in the Tremor style
- payments/export-dialog: the options dialog; counts come from
GET /api/payments so they match the file, Download disabled with no
columns selected
- csv.test: column subset order, last4 excluded by default, empty
selection, unknown columns, scope and filename (36 tests passing)
- docs/specs/NWP-101-export-options.md: the plan
Co-Authored-By: Claude Opus 5.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
Business impact: Ops can send payment exports to merchants without hand-deleting card last-four first. That removes 3–4 hours a month of manual cleanup and the near-miss that came with it.
What changed
The Export button on
/paymentsnow opens an options dialog:The download is still built on the server. The export route validates the requested columns and scope against allowlists, runs the existing query builder without paginating, and names the file after the scope and the UTC date, for example
payments-disputed-2026-11-03.csv.Files changed:
src/lib/csv.ts: default columns withoutlast4,parseExportColumns,parseExportScope,exportScopeLabel, and an optional label forexportFilename.src/app/api/payments/export/route.ts: validates before querying and returns400 { error }on bad input.src/components/Dialog.tsx(new): a Radix dialog primitive built the same way asDrawer.tsx.src/app/payments/export-dialog.tsx(new): the dialog. Its row counts come fromGET /api/payments, which uses the same parser and query builder as the file.src/app/payments/page.tsx: wires in the dialog and dropspagefrom the export query.The plan is at
docs/specs/NWP-101-export-options.md.How I verified it
Tests.
npm testinbuild-battle/merchant-console:Test Files 3 passed (3),Tests 36 passed (36). Before the new tests it was 28 passed. The 9 existingcsv.test.tstests still pass unchanged. The 8 new tests cover:last4excluded by default, with neither the header nor the value in the output""," ",","," , ")Static checks.
npx tsc --noEmitreported no errors, andnpm run lintreported "No ESLint warnings or errors".API, with curl against the dev server:
last4.columns=last4,idreturns exactlylast4,id.columns=amount,id,amount,currencyreturnsamount,id,currency.columns=returns 400 with "Choose at least one column to export."columns=id,nopereturns 400 listing the allowed columns.scope=everythingreturns 400.status=disputed&page=3returns all 33 disputed rows, namedpayments-disputed-2026-11-03.csv.scope=allreturns 1,658 rows, namedpayments-all-….payments-filtered-….Browser, on
/payments?status=disputed&page=2:page.id,last4, 1,658 rows andpayments-all-2026-11-03.csv.Checklist:
npm testpassesAcceptance criteria
payments-disputed-2026-08-13.csv.cell()callsformatMoneyonce per amount, andcurrencyis its own column. Nothing changed there, and the existing tests still pin it.columnslist with a 400.Bugs fixed along the way
None fixed. One found, see the notes below.
Notes for the reviewer
sortPaymentsinsrc/data/queries.ts:79-82sorts amounts as strings, so descending order runs 9999, 9992, 994, 9873… and $9.94 ranks above $98.73. It's outside this ticket, and the export UI never sendssort=amount, so I left it alone.filteredinstead of naming the merchant. That keeps free text out of the filename.payments/page.tsxstill builds its table filters by hand instead of callingparseFilters. I left that alone. The dialog's counts and the file both go throughparseFilters, so they agree with each other.🤖 Generated with Claude Code