Skip to content

[Frontend] Replace Mock Data Services with Real Backend API Integration #141

@KuchiMercy

Description

@KuchiMercy

Summary

The frontend currently uses mock/simulated data with fake API delays throughout services/escrow.ts. All data fetching hooks (useEscrows, useEscrow, useEvents) consume this mock layer. The frontend must be wired to the real NestJS backend API.

Current State

  • services/escrow.ts contains an EscrowService class with methods (getEscrows(), getEscrowById(), getEvents(), createEscrow(), updateEscrowStatus()) that all return hardcoded/mock data with simulated setTimeout delays (500-1000ms)
  • hooks/useWallet.ts is a mock hook returning a hardcoded test public key instead of using the real WalletContext
  • No API base URL configuration exists
  • No auth token injection in API requests
  • React Query hooks have no real endpoint backing them

Acceptance Criteria

  • Create an API client module with configurable base URL (NEXT_PUBLIC_API_URL env var)
  • Implement auth token injection (JWT from wallet auth flow) in API request headers
  • Replace all mock methods in EscrowService with real HTTP calls to backend endpoints:
    • GET /escrows (list with filters/pagination)
    • GET /escrows/:id (detail with relations)
    • POST /escrows (create)
    • POST /escrows/:id/fund (fund)
    • POST /escrows/:id/release (release)
    • POST /escrows/:id/cancel (cancel)
    • POST /escrows/:id/dispute (file dispute)
    • POST /escrows/:id/conditions/:conditionId/fulfill (fulfill)
    • POST /escrows/:id/conditions/:conditionId/confirm (confirm)
    • GET /escrows/:id/events (event history)
  • Implement the auth flow: POST /auth/challenge -> sign with wallet -> POST /auth/verify -> store JWT
  • Replace mock useWallet hook usage with real useWalletConnection from WalletContext
  • Add proper error handling, loading states, and retry logic in React Query hooks
  • Add token refresh logic using the refresh token endpoint

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions