Skip to content

Add phone number formatter for readability and unit test - #34

Open
ericksondelacruz wants to merge 2 commits into
bettergovph:mainfrom
ericksondelacruz:feat/format-number-for-readability
Open

Add phone number formatter for readability and unit test#34
ericksondelacruz wants to merge 2 commits into
bettergovph:mainfrom
ericksondelacruz:feat/format-number-for-readability

Conversation

@ericksondelacruz

@ericksondelacruz ericksondelacruz commented Sep 2, 2026

Copy link
Copy Markdown

Summary

  • Added formatPhoneNumber utility that formats Philippine phone numbers by digit length: mobile (09XX XXX XXXX), Metro Manila with area code ((02) XXXX XXXX), provincial landline ((0XX) XXX XXXX), and Metro Manila 8-digit local (XXXX XXXX). Unrecognized formats (short codes, legacy 7-digit) are returned unchanged.
  • Applied formatPhoneNumber to hotline card display labels for both primary and alternate numbers.
  • Fixed handleCall to strip non-digits before building the tel: URI, preventing RFC 3966-invalid links for numbers stored with dashes (e.g. 552-1160).
  • Added vitest and a test suite for formatPhoneNumber covering all four formats with hand-crafted cases plus data-driven tests against the full public/data/hotlines.json (759 numbers across 5 format categories).

Test plan

  • Run npm test — 10 tests pass
  • Open the app and verify hotline numbers display with
    proper spacing/grouping on cards
  • Tap a hotline button on mobile and confirm the call
    dialer opens with a clean number (no dashes or spaces)
  • Verify alternate numbers in the modal also display
    formatted and dial correctly

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

@ericksondelacruz is attempting to deploy a commit to the waffenffs' projects Team on Vercel.

A member of the Team first needs to authorize it.

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