Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Submit feedback
    • Contribute to GitLab
  • Sign in
F
finwise-miniapp-fe
  • Project
    • Project
    • Details
    • Activity
    • Releases
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
  • Issues 0
    • Issues 0
    • List
    • Board
    • Labels
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • ThinhNC
  • finwise-miniapp-fe
  • Merge Requests
  • !41

Merged
Opened Sep 12, 2026 by ThinhNC@ThinhNC
  • Report abuse
Report abuse

feat(calculator): integrate real-time market exchange rates with live badge and offline fallback

Overview

This pull request integrates real-time interbank currency exchange rate fetching into the FinWise Calculator Modal, replacing static baseline rates with automated live rate lookups, clear visual status indicators, and reliable offline fallbacks without consuming AI tokens.


Key Changes

1. Real-Time Interbank Exchange Rate Feed (src/services/currency.service.ts)

  • Live Interbank Fetching: Added fetchLiveExchangeRate(from, to) to query interbank rates via FloatRates and Open Exchange Rates with request timeouts and error handling.
  • Offline & Graceful Fallback: Automatically falls back to cached rates or modernized baseline values (DEFAULT_VND_RATES) when network requests fail or offline.
  • Updated Baseline Rates: Refreshed default hardcoded rates against VND (e.g., USD: 25,922.52, EUR: 30,067.05, JPY: 168.3, etc.).

2. Dynamic Calculator Modal UI (src/components/ui/CalculatorModal.tsx)

  • Automated Rate Fetching: Automatically triggers rate lookup when user switches fromCurrency or toCurrency.
  • Live vs Baseline Badges:
    • Displays a green Live Market badge when fetching real-time market rates.
    • Displays a Baseline indicator when serving cached or offline rates.
  • Loading State: Pulse animation with animated spinner while fetching updated rates, preventing race conditions.
  • Manual Refresh Action: Added a one-click refresh button with spinning state to pull the latest rate on demand.
  • Source Note / Tooltip: Informative tip showing the active market feed source (e.g., FloatRates, Open Exchange Rates, or identical currency notification).
  • Disabled State: Temporarily disables the "Apply" button while rates are updating to ensure arithmetic integrity.

3. AI Assistant Service & Types (src/services/ai-assistant.service.ts, src/types/ai.ts)

  • Added getExchangeRate method to aiAssistantService for direct interaction with /ai-assistant/exchange-rate.
  • Defined strongly-typed interfaces: AIExchangeRateInput and AIExchangeRateData.

4. Internationalization (src/i18n/locales/en.json, src/i18n/locales/vi.json)

  • Added complete English and Vietnamese localization keys:
    • currency.updatingRate: "Updating market rate..." / "Đang cập nhật tỷ giá..."
    • currency.liveBadge: "Live Market" / "Thị trường"
    • currency.estimated: "Baseline" / "Cơ sở"
    • currency.refreshRate: "Refresh market rate" / "Cập nhật tỷ giá thị trường"
    • currency.sameCurrencyNote: "Exchange rate for identical currencies" / "Tỷ giá giữa cùng một loại tiền tệ"

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b feat/calculator-currency-converter origin/feat/calculator-currency-converter

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git fetch origin
git checkout origin/develop
git merge --no-ff feat/calculator-currency-converter

Step 4. Push the result of the merge to GitLab

git push origin develop

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

  • Discussion 0
  • Commits 1
  • Changes 6
Assignee
No assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
0
Labels
None
Assign labels
  • View project labels
Reference: ThinhNC/finwise-miniapp-fe!41

Revert this merge request

This will create a new commit in order to revert the existing changes.

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.