Skip to content

perf: debounce + AbortController, memo rows, dynamic recharts, image docs - #277

Merged
martinzhames merged 2 commits into
dupdab:mainfrom
Teeeyanaa:perf/debounce-memo-dynamic-image-docs
Aug 29, 2026
Merged

perf: debounce + AbortController, memo rows, dynamic recharts, image docs#277
martinzhames merged 2 commits into
dupdab:mainfrom
Teeeyanaa:perf/debounce-memo-dynamic-image-docs

Conversation

@Teeeyanaa

@Teeeyanaa Teeeyanaa commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Four mechanical performance and convention fixes across the dashboard.

1. Admin settlements — debounce + AbortController (admin/settlements/page.tsx)

  • Added a separate merchantIdInput state the text field binds to, keeping the input immediately responsive while the fetch is gated.
  • A debounce effect (400 ms) copies the typed value into filters.merchantId only after the user pauses, eliminating per-keystroke round-trips.
  • The fetch effect creates a new AbortController on each run and passes { signal } to Axios. The cleanup calls controller.abort(), cancelling any superseded in-flight request and preventing out-of-order response application.
  • As a side-effect, fixes the pre-existing react-hooks/exhaustive-deps ESLint warning by moving fetchSettlements inside the effect.

2. Memoized row components — payments, settlements, webhooks

Extracted React.memo subcomponents for every list page so rows skip re-renders on parent state changes (modal open/close, loading flag) that don't affect row data:

Page Components added
payments/page.tsx PaymentTableRow, PaymentMobileCard
settlements/page.tsx SettlementTableRow, SettlementMobileCard
webhooks/page.tsx WebhookRow

Callbacks are passed as stable useState setter props so they don't break memo equality.

3. Dynamic recharts — analytics page

  • Moved PieChart logic into StatusPieChart.tsx and BarChart logic into VolumeBarChart.tsx.
  • Both loaded via next/dynamic(..., { ssr: false }) in analytics/page.tsx.
  • Recharts is now code-split into a lazy chunk fetched only when /dashboard/analytics is visited. Merchants who never visit analytics never download it.

4. next/image convention — README

Added an Images section to the Architecture section of README.md documenting next/image as the required pattern for any future merchant logos, avatars, or marketing assets — with usage examples and a note on remotePatterns in next.config.js.

Testing

  • npm run lint — no new errors introduced (all pre-existing errors confirmed via git stash before/after comparison)
  • No functional behaviour changed on any page; all changes are structural (state shape, component boundaries, import strategy)

closes #203
closes #204
closes #205
closes #206

…docs

- admin/settlements: debounce merchantId input 400ms before updating filters
  state; AbortController cancels superseded in-flight requests on each filter/
  page change and on unmount, preventing out-of-order response application.
  Also fixes pre-existing react-hooks/exhaustive-deps warning.

- payments, settlements, webhooks: extract memoized row subcomponents
  (PaymentTableRow, PaymentMobileCard, SettlementTableRow, SettlementMobileCard,
  WebhookRow) so table rows skip re-renders on parent state changes such as
  modal open/close that don't affect row data.

- analytics: replace static recharts import with next/dynamic (ssr: false)
  via two extracted components (StatusPieChart, VolumeBarChart). Recharts is
  now code-split into a lazy chunk fetched only when /dashboard/analytics is
  visited; it is excluded from the SSR pass entirely.

- README: add Images section documenting next/image as the required pattern
  for any future merchant logos, avatars, or marketing assets, with usage
  examples and a note on configuring remotePatterns in next.config.js.
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Teeeyanaa Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@martinzhames
martinzhames merged commit 05e99e6 into dupdab:main Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants