Skip to content

feat(dashboard): create audit trail list view component - #911

Merged
johdanike merged 2 commits into
SwiftChainn:mainfrom
AdaBliss:feat/audit-trail-list-view
Sep 30, 2026
Merged

johdanike merged 2 commits into
SwiftChainn:mainfrom
AdaBliss:feat/audit-trail-list-view

Conversation

@AdaBliss

Copy link
Copy Markdown
Contributor

closes #796

Summary

Adds AuditTrailList, a read-only list view of the immutable blockchain events for a delivery. Each event is a card with its type, timestamp, actor and metadata, shown newest first. It follows the Component -> Hook -> Service pattern.

Changes

  • components/dashboard/AuditTrailList.tsx (new)
    • Each event is a card showing the event type, a <time> timestamp, the actor (display name, shortened address with the full address on hover, and role), transaction hash, ledger sequence and a metadata key/value grid.
    • Events are listed newest first, with a toggle to show oldest first.
    • The event ID has a copy-to-clipboard button with "Copied" feedback, announced to screen readers through aria-live.
    • While loading, a skeleton card is shown for each placeholder, with a screen-reader status message.
    • An empty state with a Retry button, an error state with a Retry button, and a prompt to select a delivery when none is selected.
    • Keyboard navigation: every card is focusable with Tab. Arrow Up/Down, Home and End move between cards, and focus rings are visible.
    • Responsive, and works in light and dark mode.
  • hooks/useAuditTrail.ts (new): a TanStack Query hook. It provides sorted events (invalid timestamps sort last), the sort order state, retry, and copyEventId with an auto-resetting copiedEventId.
  • services/auditTrailService.ts (new): getDeliveryEvents(deliveryId) calls GET /api/audit/delivery/{deliveryId}/events and throws on failure so the hook can track error state.
  • types/auditTrail.ts (new): event and actor types.
  • components/dashboard/index.ts: exports AuditTrailList.

The existing AuditTimeline and auditService are unchanged.

Tests

  • services/__tests__/auditTrailService.test.ts: endpoint, id encoding, error messages.
  • hooks/__tests__/useAuditTrail.test.tsx: newest-first default, sort toggle, no fetch without a delivery, error and retry, clipboard copy, copied reset, clipboard failure, sort stability.
  • components/dashboard/__tests__/AuditTrailList.test.tsx: the real hook runs and only the service is mocked. Covers:
    • Chronological order and the sort toggle.
    • Card metadata.
    • Copy to clipboard.
    • Loading skeletons.
    • Empty state with retry, and error state with retry.
    • The no-delivery prompt.
    • Keyboard navigation.
PASS services/__tests__/auditTrailService.test.ts
PASS hooks/__tests__/useAuditTrail.test.tsx
PASS components/dashboard/__tests__/AuditTrailList.test.tsx
Tests: 27 passed, 27 total

Fixtures live under hooks/__tests__/fixtures. The component, hook and service contain no inline mock data.

Checks

  • ESLint on changed files: 0 errors, 0 warnings.
  • TypeScript: the changed files type-check cleanly. Project-wide pnpm type-check currently fails on main because of parse errors in app/page.tsx and components/escrow/__tests__/CheckoutFlow.keyboard.test.tsx, which this PR does not touch.
  • Full pnpm test: this PR adds no new failing suites. The suites that fail on main are unchanged.

Screenshots

Unit test run output is included above.

- Add AuditTrailList: read-only card list of immutable blockchain events
  for a delivery showing event type, timestamp, actor, transaction,
  ledger and metadata
- Order events newest first with a toggle to oldest first
- Add copy-to-clipboard for event IDs with copied feedback
- Add per-card loading skeletons, an empty state with retry, an error
  state with retry, and a no-delivery prompt
- Make cards keyboard navigable with Tab, Arrow Up/Down, Home and End
- Add useAuditTrail hook and auditTrailService for
  GET /api/audit/delivery/{id}/events
- Add service, hook and component unit tests
@drips-wave

drips-wave Bot commented Sep 29, 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

@johdanike
johdanike merged commit c1998f7 into SwiftChainn:main Sep 30, 2026
0 of 2 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.

Frontend: Smart Contract Audit Trail - List View Component

2 participants