Skip to content

Feat/cross border preview - #58

Merged
johdanike merged 4 commits into
SwiftChainn:mainfrom
solomonadzape95:feat/cross-border-preview
Apr 26, 2026
Merged

Feat/cross border preview#58
johdanike merged 4 commits into
SwiftChainn:mainfrom
solomonadzape95:feat/cross-border-preview

Conversation

@solomonadzape95

Copy link
Copy Markdown
Contributor

Summary

This PR adds a cross-border fiat-to-XLM preview for delivery creation, using backend exchange-rate data with React Query and a strict Component -> Hook -> Service architecture.

What was implemented

  • Added React Query provider wiring:
    • app/providers.tsx
    • Updated app/layout.tsx to wrap app with QueryClientProvider (via Providers)
  • Added service layer:
    • services/currencyRateService.ts
    • Fetches rates from GET /api/rates/xlm?fiat=<CODE>
    • Validates response shape { fiat, xlmRate, updatedAt }
  • Added hook layer:
    • hooks/useCurrencyConverter.ts
    • Fetches live rate with React Query
    • Computes dynamic xlmEstimate from entered fiat amount
    • Exposes safe UI state: isLoading, isError, rate, xlmEstimate, lastUpdated, refetch
  • Added component layer:
    • features/deliveries/components/CurrencyConverter.tsx
    • Renders local currency selector, fiat amount input, and XLM estimate preview
    • Handles API failure gracefully with fallback messaging and retry action
  • Mounted the feature:
    • app/(dashboard)/deliveries/create/page.tsx
    • Displays <CurrencyConverter /> in delivery creation flow
  • Added tests:
    • hooks/__tests__/useCurrencyConverter.test.ts
    • Covers conversion success flow, currency-change refetch behavior, and API-unavailable fallback state

Acceptance Criteria Mapping

  • Real-time estimated conversion rate: ✅
  • Fetch rate from backend API and update totals dynamically: ✅
  • Graceful fallback if price API is unavailable: ✅
  • Strict Component -> Hook -> Service layered architecture: ✅
  • No inline mock objects in implementation data flow: ✅

Technical Notes

  • API contract used: GET /api/rates/xlm?fiat=<CODE>
  • Expected response: { fiat, xlmRate, updatedAt }
  • Fallback behavior on API failure:
    • Keep user-entered amount/currency intact
    • Show Rate unavailable, try again
    • Keep estimate unavailable until data is recovered
    • Provide manual retry (refetch)

Test Plan

  • Run unit tests:
    • bun run test hooks/__tests__/useCurrencyConverter.test.ts
  • Verify converter renders in create-delivery page
  • Verify successful conversion math updates with amount changes
  • Verify graceful fallback UI when API fails
  • Verify retry action requests rate again

Work Summary

Implemented a backend-driven fiat-to-XLM preview experience in the delivery creation flow with React Query, robust fallback handling, and tests for core conversion and failure scenarios.

Closes #48

…figuration files, package dependencies, and development environment settings.
- Added onboarding tour functionality using react-joyride.
- Created Tour component to manage the tour steps and UI.
- Integrated tour steps into dashboard layout and various pages.
- Updated package.json and bun.lock to include react-joyride dependency.
- Added hooks and services for managing tour state and persistence.
- Enhanced UI elements with data attributes for tour targeting.
…pment environment

- Deleted various JSON and JavaScript manifest files related to build, routes, and server configurations.
- Cleaned up cache files and traces associated with the development build process.
- Removed client and server reference manifests, as well as app paths and font manifests, to streamline the project structure.
…related hooks

- Added CurrencyConverter component for real-time fiat-to-XLM conversion.
- Created useCurrencyConverter hook to manage currency state and API interactions.
- Integrated currency converter into the CreateDeliveryPage.
- Established currencyRateService for fetching exchange rates from the API.
- Added tests for useCurrencyConverter to ensure functionality and error handling.
- Refactored layout to use Providers for theme and query context management.
@drips-wave

drips-wave Bot commented Apr 25, 2026

Copy link
Copy Markdown

@solomonadzape95 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 53c90aa into SwiftChainn:main Apr 26, 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: Cross-Border Fiat-to-XLM Preview

2 participants