Skip to content

feat: admin refund processing hook, views, timeline panel and driver KYC onboarding flow - #945

Open
AdaBliss wants to merge 2 commits into
SwiftChainn:mainfrom
AdaBliss:feat/admin-refunds-and-kyc-onboarding
Open

AdaBliss wants to merge 2 commits into
SwiftChainn:mainfrom
AdaBliss:feat/admin-refunds-and-kyc-onboarding

Conversation

@AdaBliss

Copy link
Copy Markdown
Contributor

Summary

This PR resolves the four Stellar Wave issues assigned to AdaBliss:

Layering follows Component -> Hook -> Service throughout. No inline mock data is used; every response comes from the backend API.

closes #809
closes #810
closes #811
closes #812

Implementation

#809 useAdminRefunds hook

  • hooks/useAdminRefunds.ts: TanStack infinite query over GET /admin/refunds, with status, date range and search filters, cursor pagination, refetch, fetchNextPage for infinite scroll, and bulkMarkReviewed that resolves with { successCount, errorCount } and invalidates the list.
  • hooks/useRefundViewState.ts: shared filter and selection state for the three views.
  • services/adminRefundService.ts: Axios calls for list, bulk review and timeline. Filters are sent as query params and empty values are omitted.
  • services/exportDataService.ts: new toCsv and exportToCsv. CSV output is RFC 4180 and cells that begin with =, +, -, @ or a tab are quoted to block spreadsheet formula injection.

#810 RefundTimelineDetail panel

  • components/admin/RefundTimelineDetail.tsx renders events in chronological order with description, action badge, timestamp, actor, optional transaction hash and event ID.
  • Every identifier has click-to-copy with a short "copied" indicator.
  • A print button and print: utility classes provide a print-friendly layout.
  • A view prop (list | grid | table) lets the panel sit alongside any admin view.
  • hooks/useRefundTimeline.ts loads the timeline through adminRefundService and sorts it by timestamp.

#811 Admin refund view tests

  • The List, Grid and Table views live in components/admin/refunds/, with /admin/refunds as the page that hosts them.
  • The Grid view can show and hide columns. The Table view uses @tanstack/react-virtual so only the visible rows are rendered.
  • components/admin/__tests__/AdminRefundViews.test.tsx runs 40 cases across the three views (metadata, column toggle, virtualized rows, filters, empty and error states, bulk selection, CSV export). The hook is mocked, as the issue asks.

#812 KYC onboarding flow

  • components/onboarding/KycOnboardingFlow.tsx is a four-step flow: driver's license front and back, vehicle registration, profile photo, review and submit. It replaces KycUpload on /driver/kyc.
  • hooks/useKycOnboarding.ts uses react-hook-form with a zod schema. Each file must be a PDF, JPG or PNG and no larger than 5 MB.
  • The step indicator marks the active and completed steps. Earlier steps are clickable. Next is blocked until the current step validates.
  • Submit uploads each document, then calls kycService.submitForApproval with the returned document IDs.
  • The layout stacks vertically on small screens.

Tests and results

Commands run from the repository root with Node and the lockfile dependencies:

Command Result
npx jest components/admin hooks/__tests__/useAdminRefunds.test.tsx services/__tests__/adminRefundService.test.ts components/onboarding 5 suites, 73 tests, all passing
npx jest (full suite) Same 52 suites fail on upstream main and on this branch. This branch adds no new failures.
npx tsc --noEmit No errors in the files changed here. The only error is in the existing components/escrow/__tests__/HighValueCargoMultiSigModal.test.tsx.
npx eslint on changed files 0 errors, 17 warnings (unused parameters in interface stubs and a React Compiler notice on useVirtualizer)
npx next build Fails in app/figma/ERROR_BOUNDARY_EXAMPLES.tsx (children missing in GlobalErrorBoundary props). That file is unchanged from main and is unrelated to this PR.

Coverage for the new code measured with --coverage: RefundListView, RefundTableView and useAdminRefunds are at 100% statements and lines. RefundGridView is at 96% statements. The lowest branch figure is 64.5% for useKycOnboarding.

Compatibility and security

  • services/refundService.ts already exists on main for the customer cancellation and refund-tracking flow. It is left unchanged. The admin service lives in services/adminRefundService.ts to avoid a collision.
  • No existing public interfaces are changed. exportDataService gains two methods; kycService gains submitForApproval. The /driver/kyc route keeps its path and default export.
  • Client-side file checks are a usability aid only. The backend must still validate type and size.
  • CSV export neutralises formula-leading characters. Identifiers are copied with the Clipboard API; failures are caught and reported as false.

Known limitations and open items

  • Backend endpoints are assumed, not verified. /admin/refunds, /admin/refunds/bulk-review, /admin/refunds/:id/timeline and /api/kyc/submit were chosen from the issue text and must be checked against the API.
  • Screenshots are not included. The issues require screenshots of implementations and passing tests. They must be added by the author before review.
  • AI-generated submissions. The issues state that AI-generated PR submissions are disallowed. This PR was drafted with an AI coding assistant. The author should confirm they have reviewed, understood and can answer for every change before the maintainers review it.
  • The full test suite has 52 failing suites that already fail on main. They are unrelated to this PR.
  • The Next.js production build fails on main in app/figma/ERROR_BOUNDARY_EXAMPLES.tsx, so the build check cannot pass until that is fixed upstream.

…nd KYC onboarding flow

- hooks/useAdminRefunds: infinite-query refund list with status, date range
  and search filters, cursor pagination, bulkMarkReviewed and CSV export
- components/admin: refund List, Grid and virtualized Table views and a
  reusable RefundTimelineDetail panel with click-to-copy identifiers and
  print styles; adds /admin/refunds page
- services: refundService, CSV export in exportDataService (with formula
  injection protection), kycService.submitForApproval
- components/onboarding: four-step KycOnboardingFlow with step indicator,
  react-hook-form and zod validation; used by the driver KYC page
- tests for views, hook, services, timeline panel and onboarding flow
… table

The installed virtual-core reads offsetHeight/offsetWidth to size the scroll
container, while earlier versions read clientHeight/clientWidth. Mock both so
the table renders its row window in jsdom regardless of the version.
@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@AdaBliss 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant