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
  • !37

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

feat(fe): integrate amount calculator modal across all forms and resolve type issues

Overview

This pull request brings the transaction calculator functionality to all forms and modals with amount inputs across the FinWise mini-app. It creates a unified, reusable CalculatorModal component and implements adaptive placement rules tailored to different form layouts (2-column grids, currency-adjacent rows, and single-column fields). Additionally, it resolves TypeScript compiler issues related to Array.prototype.flatMap and React Hook Form's setValue.


Key Changes

1. Unified Shared Calculator Component

  • Created src/components/ui/CalculatorModal.tsx exporting:
    • CalculatorButton: Standard Claymorphism button (46px x 46px) matching the app's tactile design system.
    • CalculatorModal: Modal supporting keypad input, standard arithmetic (+, -, ×, ÷), rapid trailing-zero appending (85 + 175 = 260 ➔ typing 000 ➔ 260000), dynamic font scaling for large amounts, and an instant "Done" (Xong) action that commits the value into React Hook Form.
  • Maintained 100% backward compatibility by re-exporting CalculatorModal from src/pages/transactions/components/TransactionCalculatorModal.tsx.

2. Adaptive Layout Placement

Integrated the calculator into all amount-related forms based on specific UX rules:

  • Two-Column Forms (Type + Amount): Calculator placed in the center between Type and Amount ([Type] ➔ [Calculator] ➔ [Amount]).
    • TransactionFormModal.tsx
    • RecurringTransactionFormModal.tsx
  • Currency-Adjacent Forms (Amount/Limit + Currency): Calculator placed after the currency column ([Amount / Limit / Balance] ➔ [Currency] ➔ [Calculator]), keeping amount and currency visually paired.
    • BudgetFormModal.tsx
    • SavingGoalFormModal.tsx
    • WalletFormModal.tsx
  • Single-Column Forms: Calculator placed at the end of the amount row ([Amount] ➔ [Calculator]).
    • TransferFormModal.tsx
    • ContributionFormModal.tsx
    • SimulationControls.tsx
    • AnomalyChecker.tsx

3. Bug Fixes & TypeScript Modernization

  • tsconfig.json: Upgraded compiler "lib" from legacy ES2018 to ["dom", "dom.iterable", "esnext"] to natively support Array.prototype.flatMap and modern Intl options without TS2550 errors in IDEs.
  • Safe Tree Flattening: Refactored flattenTree in TransactionFormModal.tsx to use a safe recursive iterative approach with guard checks for null/undefined child nodes.
  • Missing setValue Destructuring: Fixed Cannot find name 'setValue' (TS2304) by explicitly destructuring setValue from useForm in ContributionFormModal.tsx and AnomalyChecker.tsx.

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/universal-amount-calculator origin/feat/universal-amount-calculator

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/universal-amount-calculator

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 18
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!37

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.