Skip to content

feat: add trade history CSV export button on portfolio page (#857) - #1266

Open
whitezaddy wants to merge 1 commit into
accesslayerorg:devfrom
whitezaddy:feat/857-trade-history-csv-export
Open

whitezaddy wants to merge 1 commit into
accesslayerorg:devfrom
whitezaddy:feat/857-trade-history-csv-export

Conversation

@whitezaddy

Copy link
Copy Markdown
Contributor

Summary

Closes #857

  • Implemented issue Add a trade history CSV export button on the portfolio page #857 by adding an Export CSV button to the trade history tab header on the portfolio page (/profile?tab=trade-history).
  • Added ExportTradeHistoryCsvButton component with authenticated access check, loading spinner (Loader2), and accessibility attributes (aria-busy).
  • Fetches all trade history records from GET /users/:wallet/trades without pagination limits via cursor-traversal in fetchAllTrades.
  • Formats CSV with RFC 4180 escaping, spreadsheet formula injection protection, and exact headers: Date, Key Name, Type, Quantity, Price per Key, Total, Fee.
  • Generates file download with filename formatted as trades-[wallet-truncated]-[date].csv via buildTradeHistoryCsvFilename.

Testing

  • pnpm lint — passed with 0 errors, 0 warnings
  • pnpm build — production TypeScript and Vite bundle build passed
  • pnpm test — all 33 related unit and integration tests passed:
    • src/utils/__tests__/tradeExport.utils.test.ts (CSV headers, rows, calculations, escaping, and filename)
    • src/components/common/__tests__/ExportTradeHistoryCsvButton.test.tsx (auth visibility, loading spinner, complete trade fetch, and download trigger)
    • src/pages/__tests__/ProfilePage.integration.test.tsx (tab header button presence and unauthenticated hiding)
    • src/components/common/__tests__/TradeHistoryLedger.test.tsx (pre-existing table tests preserved)

Checklist

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.

Add a trade history CSV export button on the portfolio page

1 participant