feat(ui): format phone numbers for display#873
Merged
cpcloud merged 7 commits intomicasa-dev:mainfrom Mar 31, 2026
Merged
Conversation
c9d6185 to
4049adc
Compare
Design spec for micasa-dev#860 — formatting vendor phone numbers for display using nyaruka/phonenumbers with per-vendor locale support. Covers data model, formatting function, all display surfaces (TUI table, CLI show, extraction preview), sync compatibility, and testing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12-task TDD plan covering FormatPhoneNumber, Vendor.Locale model field, cellTelephoneNumber kind, table/CLI/extraction formatting, form round-trip, and inline edit tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Parses and formats phone numbers using nyaruka/phonenumbers. Uses region comparison to choose NATIONAL vs INTERNATIONAL format, with country-code fallback for fictional numbers (e.g. 555-xxxx). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds Locale field to Vendor model and cellTelephoneNumber kind. Formats phone numbers at row-build time using per-vendor locale with system-default fallback. Wires formatting into the TUI table, extraction preview, and preserves Locale through form round-trips. closes micasa-dev#860 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Table output uses FormatPhoneNumber with vendor locale fallback. JSON output preserves raw phone values for machine consumption. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
For fictional numbers (no parsed region) with a "+" prefix under a shared calling code (e.g. +1 for US/CA), use INTERNATIONAL format to avoid misattribution. Local numbers without "+" prefix still format as NATIONAL since the user is entering a domestic number. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gofakeit.Phone() produces numbers starting with 0 or 1 (~11% of the time), which libphonenumber misparses (leading 1 is treated as country code, leaving too few digits). Replace with a helper that generates area codes and exchanges starting with 2-9 per NANP rules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
4049adc to
0655e17
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FormatPhoneNumberininternal/locale/phone.gousingnyaruka/phonenumbersfor international phone formatting (NATIONAL for same-region, INTERNATIONAL for foreign numbers)Localefield toVendormodel (ISO 3166-1 alpha-2, empty = system default viaDetectCountry())cellTelephoneNumberkind with explicit exhaustive switch casesshow vendorstext output, and extraction previewLocalethrough form round-trips; leaveFindOrCreateVendoruntouchedshow vendorsoutput keeps raw phone values for machine consumption+prefix presence for fictional numberscloses #860