Skip to content

feat(institutions): add filtering and sorting functionality for institution#503

Open
sundayonah wants to merge 1 commit into
mainfrom
refactor/noblocks-shared-institution-sort
Open

feat(institutions): add filtering and sorting functionality for institution#503
sundayonah wants to merge 1 commit into
mainfrom
refactor/noblocks-shared-institution-sort

Conversation

@sundayonah
Copy link
Copy Markdown
Collaborator

@sundayonah sundayonah commented May 18, 2026

Summary

  • Extract shared institution list logic into filterAndSortInstitutions and compareInstitutionsForDisplay in app/utils.ts.
  • Add NGN_PRIORITY_INSTITUTION_CODES (Opay, PalmPay, Moniepoint, Kuda) so sort order is defined in one place.
  • Use the shared helper in off-ramp (RecipientDetailsForm → Select institution modal) and on-ramp (AddRefundAccountModal refund bank picker) so both flows show the same order.

Description

Off-ramp institution selection already sorted providers with mobile money first, pinned NGN fintech codes, then A–Z. On-ramp refund account setup only sorted mobile money first and then A–Z, so popular fintechs (Opay, PalmPay, Moniepoint, Kuda) did not appear in the same positions as on the swap flow.

This PR centralizes filter and sort behavior so both pickers stay consistent and easier to maintain.

Sort order:

  1. mobile_money institutions first
  2. Pinned NGN fintechs: Opay → PalmPay → Moniepoint → Kuda (OPAYNGPC, PALMNGPC, MONINGPC, KUDANGPC)
  3. Remaining institutions A–Z by name (localeCompare)
  4. Search still filters by institution name (case-insensitive)

Files touched:

  • app/utils.tsNGN_PRIORITY_INSTITUTION_CODES, compareInstitutionsForDisplay, filterAndSortInstitutions
  • app/components/recipient/RecipientDetailsForm.tsx — off-ramp Select institution modal
  • app/components/AddRefundAccountModal.tsx — on-ramp refund bank selection step

Breaking changes: None (display order only).

Alternatives considered: Duplicating the comparator in AddRefundAccountModal (rejected; drift risk). Strict A–Z only (rejected; product wants mobile money and priority fintechs on top).

API / contracts: No API or database changes.

References

N/A

Testing

Manual:

  1. Off-ramp (NGN): Swap → Off-ramp → Select institution. Confirm mobile money and Opay / PalmPay / Moniepoint / Kuda at the top, then banks A–Z. Search should filter and preserve sort.
  2. On-ramp: On-ramp flow → add or edit refund account → open bank list. Confirm the same order as off-ramp.
  3. Optional: another currency; order should remain mobile money → priority codes (when present) → A–Z.
  • on-ramp
On-ramp refund institution list matches off-ramp sort order
  • off-ramp
Screenshot 2026-05-18 105232

Checklist

  • I have added documentation and tests for new/changed functionality in this PR
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used, if not main

By submitting a PR, I agree to Paycrest's Contributor Code of Conduct and Contribution Guide.

Summary by CodeRabbit

  • Refactor
    • Unified institution filtering and sorting logic across the application. Bank and financial institution lists now use consistent filtering and ordering rules in all dropdown menus and selection dialogs, providing a more coherent experience across different forms and workflows.

Review Change Stack

…tution selection

- Introduced `filterAndSortInstitutions` function to filter institutions by name and sort them, prioritizing mobile money types and specific NGN institution codes.
- Updated `AddRefundAccountModal` and `RecipientDetailsForm` components to utilize the new filtering and sorting logic, improving code readability and maintainability.
- Added a constant for NGN priority institution codes to streamline sorting logic.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 18, 2026

📝 Walkthrough

Walkthrough

This PR consolidates duplicated institution filtering and sorting logic from two components into shared utilities. app/utils.ts now exports NGN-specific institution prioritization constants and helpers that both AddRefundAccountModal and RecipientDetailsForm use to filter and sort institution lists consistently.

Changes

Institution Filtering and Sorting Consolidation

Layer / File(s) Summary
Shared institution filtering and sorting utilities
app/utils.ts
Introduces NGN_PRIORITY_INSTITUTION_CODES, compareInstitutionsForDisplay (orders by mobile_money priority, then NGN pinned codes, then alphabetical), and filterAndSortInstitutions (case-insensitive name filtering + sorting via comparator).
Component refactoring to use shared utilities
app/components/AddRefundAccountModal.tsx, app/components/recipient/RecipientDetailsForm.tsx
Both components import and call filterAndSortInstitutions to replace inline filtering and sorting logic, removing duplicated code and consolidating institution ordering rules.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 Hop, hop, the banks align—
With mobile money's glorious shine!
Shared sorting rules now center stage,
Two components turn the page. 🏦✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description is comprehensive and well-structured, covering summary, technical details, alternatives considered, manual testing steps with screenshots, and checklist completion status.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The PR title accurately describes the main change: adding filtering and sorting functionality for institutions shared across components. It directly relates to the primary objective of extracting and centralizing institution filtering/sorting logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/noblocks-shared-institution-sort

Comment @coderabbitai help to get the list of available commands and usage tips.

@sundayonah sundayonah changed the title feat(institutions): add filtering and sorting functionality for insti… feat(institutions): add filtering and sorting functionality for institution May 18, 2026
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.

1 participant