Skip to content

Feat/refund management UI#131

Open
Ekene001 wants to merge 4 commits into0xdevcollins:mainfrom
Ekene001:feat/Refund-Management-UI
Open

Feat/refund management UI#131
Ekene001 wants to merge 4 commits into0xdevcollins:mainfrom
Ekene001:feat/Refund-Management-UI

Conversation

@Ekene001
Copy link
Copy Markdown
Contributor

@Ekene001 Ekene001 commented Apr 6, 2026

closes #89

Description:

Adds a complete refund management system to the payment dashboard, including a refund action flow in the payment detail drawer, a dedicated refunds page, and real-time webhook-driven UI updates.

What this PR does

Refund action in payment detail

  • "Issue Refund" button in [PaymentDetailDrawer] visible only when the payment is completed, within the 180-day refund window, and not already fully refunded
  • Refund status badge (Refund Pending / Refunded / Partial Refund) displayed alongside primary status
  • Refund detail cards showing amount, status, estimated delivery, and notes
  • Refund activity appended to the payment timeline

Refund modal

  • Two-step flow: form → confirmation
  • Full/partial refund toggle with segmented control
  • Amount field: pre-filled, readonly for full refunds, validated for partial (no zero/negative, cannot exceed original)
  • Required reason dropdown (customer_request, duplicate, fraudulent, other)
  • Optional notes textarea with 500-char limit and live counter
  • Refund rules info block with days remaining and estimated delivery
  • Confirmation step with plain-language warning about irreversibility and processing time
  • Loading state and success/error toast notifications on submission

Refund history page

  • New [/refunds] route with filterable, sortable, paginated table
  • Columns: Payment ID, Refund Amount, Reason, Status, Initiated Date, Completed Date
  • Status filter tabs: All, Pending, Processing, Completed, Failed
  • Added "Refunds" nav item to sidebar

Webhook event support

  • [useRefundEvents] hook subscribes to [refund:created] and [refund:completed] socket events
  • Auto-invalidates payment, refund, and list caches on event receipt
  • Toast notifications for real-time status changes
  • Integrated at dashboard layout level so it runs across all pages

Status badge updates

  • [REFUNDING]→ "Refund Pending" (yellow/pending variant)
  • [REFUNDED] → "Refunded" (green/completed variant)
  • New [RefundStatusBadge] component for Partial Refund (blue/processing variant)
  • [PaymentTimeline] now renders REFUNDED/REFUNDING as completed payment flows instead of error states

Helpers

  • [getRefundEta(paymentMethod)] — returns estimated delivery time (Card: 5–10 days, Bank: 1–3 days, Crypto: minutes)
  • [canRefund()], isWithinRefundWindow(), [refundWindowDaysRemaining()]
  • Refund types, payload interfaces, and reason constants

New files

  • src/lib/refund.ts — types, constants, helper functions
  • src/hooks/useRefunds.ts — React Query hooks for refund CRUD
  • src/hooks/useRefundEvents.ts — WebSocket event listener
  • src/components/payments/RefundModal.tsx — 2-step refund dialog
  • src/components/payments/RefundTimeline.tsx — refund activity timeline
  • src/components/payments/RefundStatusBadge.tsx — refund state badge
  • src/components/payments/RefundHistoryTable.tsx — filterable refund table
  • src/app/(dashboard)/refunds/page.tsx — refunds page route

Modified files

  • src/components/payments/PaymentDetailDrawer.tsx — refund button, badges, detail section, timeline
  • src/components/payments/StatusBadge.tsx — updated variants/labels for refund states
  • src/components/payments/PaymentTimeline.tsx — refund-aware timeline rendering
  • src/components/app-sidebar.tsx — added Refunds nav item
  • src/app/(dashboard)/layout.tsx — wired up [useRefundEvents()]

Ekene001 added 4 commits April 5, 2026 23:06
- Refactored theme management in ThemeProvider to support user preferences (light, dark, system).
- Updated Topbar and SiteHeader components to reflect theme changes with appropriate icons and tooltips.
- Enhanced InvoicesTable and InvoiceDrawer components with consistent status badge styling.
- Adjusted QR code modal and link creation components for improved visual consistency.
- Fixed encoding issues in InvoiceDrawer and GreetingHeader components.
- Improved accessibility by adding aria-labels and titles for theme toggle buttons.
…/implement-dark-mode-system-for-merchant-dashbaord
- Added refund modal for issuing refunds with full and partial options.
- Integrated refund history table to display all refunds with filtering and pagination.
- Enhanced payment detail drawer to show refund status and action buttons.
- Created refund timeline component to visualize refund events.
- Implemented refund status badges for better UX.
- Introduced hooks for managing refund data and events.
- Updated payment timeline to reflect refund statuses.
- Added utility functions for refund management, including validation and ETA calculations.
- Improved status badges for payments to reflect refunding and refunded states.
@Ekene001
Copy link
Copy Markdown
Contributor Author

Ekene001 commented Apr 6, 2026

@0xdevcollins pls review

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.

Dashboard: Refund Management UI — Initiate & Track Refunds

1 participant