Skip to content

fix: reuse shared csvExport utility in ActivityHistory export (#1266) - #1371

Merged
K1NGD4VID merged 3 commits into
LabsCrypt:mainfrom
Blessed-Femi:fix/1266-reuse-csv-export-utility
Sep 2, 2026
Merged

fix: reuse shared csvExport utility in ActivityHistory export (#1266)#1371
K1NGD4VID merged 3 commits into
LabsCrypt:mainfrom
Blessed-Femi:fix/1266-reuse-csv-export-utility

Conversation

@Blessed-Femi

Copy link
Copy Markdown
Contributor

Summary

Closes #1266

ActivityHistory had its own ad-hoc CSV export that joined cells with a bare , and duplicated the blob/anchor-click download mechanics — while frontend/src/utils/csvExport.ts already provided a shared, properly-escaping implementation (convertArrayToCSV / downloadCSV). This PR removes the duplicated logic and routes the dashboard activity export through the shared utility.

Problem

  • CSV rows were built with [headers, ...rows].map((e) => e.join(",")).join("\n") — no escaping of commas, double quotes, or newlines.
  • Any field containing a comma or quote would shift columns and corrupt the exported file when opened in spreadsheet apps.
  • The download mechanics (Blob creation, hidden anchor click) were duplicated from csvExport.ts.

Changes

  • frontend/src/components/dashboard/ActivityHistory.tsx
    • exportToCSV now maps events to row objects (same columns as before: Stream ID, Event Type, Amount, Timestamp, Tx Hash) and calls the shared downloadCSV(rows, filename).
    • Removed ~25 lines of duplicated Blob/anchor-click code and the unescaped .join(",").
    • Output format preserved: ISO timestamps, formatted amounts, empty string for missing tx hash, flowfi_activity_<timestamp>.csv filename.
  • frontend/src/components/dashboard/ActivityHistory.test.tsx (new)
    • Verifies the export calls the shared downloadCSV with the expected row data and filename.
    • Verifies a field containing commas and double quotes yields a correctly quoted/escaped, spreadsheet-safe CSV via the shared convertArrayToCSV.
    • Verifies the export button is disabled when there are no events.

Acceptance criteria

  • Exporting activity containing commas/quotes in any field produces a correctly escaped, spreadsheet-safe CSV — covered by the new component test plus the existing csvExport.test.ts escaping tests.

Verification

  • vitest run — 33 test files / 289 tests passing.
  • eslint on changed files — 0 errors.
  • tsc --noEmit — no new type errors (the 26 pre-existing errors in unrelated test files are unchanged).

Fixes #1266

Blessed-Femi and others added 3 commits August 30, 2026 13:02
…ypt#1266)

ActivityHistory built CSV rows with unescaped .join(",") and duplicated
the blob/anchor-click download mechanics already implemented in
frontend/src/utils/csvExport.ts. Replace it with downloadCSV so fields
containing commas, quotes, or newlines are properly escaped, preventing
data corruption on export. Add component test coverage verifying the
export delegates to the shared utility and produces a spreadsheet-safe
CSV.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Merging main into this branch kept main's inline CSV serialization and
dropped the downloadCSV call from the export handler, breaking the branch's
own component tests. Restore delegation to the shared csvExport utility so
fields containing commas/quotes/newlines are escaped correctly.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@K1NGD4VID
K1NGD4VID merged commit e7490ea into LabsCrypt:main Sep 2, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Audit] CSV export logic duplicated instead of reusing the shared, properly-escaping utility

2 participants