Skip to content

SettlementsPanel's "Export CSV" only exports the first loaded page, silently dropping rows loaded via "Load more #257

Description

@Jagadeeshftw

📌 Description

SettlementsPanel's handleExport (src/components/SettlementsPanel.tsx) calls exportSettlementsCsv({ pageSize }), passing only the current page size and no page. exportSettlementsCsv (src/lib/settlementsApi.ts) defaults to the server's page-1 behavior whenever page is omitted. If a user has clicked "Load more" one or more times — which appends additional pages of settlements into the on-screen table via loadMore() — clicking "Export CSV" afterward still only downloads the FIRST pageSize rows from the server, not the full set of rows currently visible in the table. A user who has scrolled through, say, 120 loaded settlements across several "Load more" clicks and exports a CSV gets a file containing only the first 10–50, with no indication anything was left out.

🧩 Requirements and context

  • handleExport should export a CSV that covers (at minimum) all settlements currently loaded into the panel via "Load more", not just the first page.
  • If the backend's CSV endpoint has no way to request "all currently-loaded pages" in one call, either loop exportSettlementsCsv across the loaded page range and concatenate, or clearly communicate in the UI (e.g. via the button's label/tooltip, or a toast) that the export is scoped to the first page only — do not leave the current silent mismatch as-is.
  • Preserve the existing exporting button-disabled state and success/failure toast behavior.

🛠️ Suggested execution

  • Track how many pages have been loaded (derivable from state.pagination.page at export time) and update handleExport in src/components/SettlementsPanel.tsx to request that many pages' worth of CSV data (e.g. sequential exportSettlementsCsv({ page, pageSize }) calls concatenated, skipping the repeated CSV header on subsequent pages), or take the "clearly communicate the limitation" fallback if a bulk-export endpoint isn't feasible in scope.
  • Extend src/components/SettlementsPanel.test.tsx and src/lib/settlementsApi.test.ts to assert the export reflects all loaded pages (or clearly documents the chosen scope) after one or more "Load more" clicks.

✅ Acceptance criteria

  • Exporting CSV after one or more "Load more" clicks either includes all currently-loaded settlements, or the UI clearly communicates that only the first page is exported.
  • Existing export loading state and toast behavior are unchanged.
  • Test coverage for the chosen behavior.

🔒 Security notes

No new attack surface; the export reuses the backend's existing read-only CSV endpoint.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26bugSomething isn't workingfrontendFrontend / UI work

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions