Skip to content

feat(ui): format phone numbers for display#873

Merged
cpcloud merged 7 commits intomicasa-dev:mainfrom
cpcloud:worktree-mutable-humming-swing
Mar 31, 2026
Merged

feat(ui): format phone numbers for display#873
cpcloud merged 7 commits intomicasa-dev:mainfrom
cpcloud:worktree-mutable-humming-swing

Conversation

@cpcloud
Copy link
Copy Markdown
Collaborator

@cpcloud cpcloud commented Mar 30, 2026

Summary

  • Add FormatPhoneNumber in internal/locale/phone.go using nyaruka/phonenumbers for international phone formatting (NATIONAL for same-region, INTERNATIONAL for foreign numbers)
  • Add Locale field to Vendor model (ISO 3166-1 alpha-2, empty = system default via DetectCountry())
  • Add cellTelephoneNumber kind with explicit exhaustive switch cases
  • Format phones in the TUI vendor table, CLI show vendors text output, and extraction preview
  • Preserve Locale through form round-trips; leave FindOrCreateVendor untouched
  • JSON show vendors output keeps raw phone values for machine consumption
  • Handle shared calling codes (+1 US/CA) by checking + prefix presence for fictional numbers

closes #860

@cpcloud cpcloud added enhancement New feature or request ux User experience labels Mar 30, 2026
@cpcloud cpcloud force-pushed the worktree-mutable-humming-swing branch 4 times, most recently from c9d6185 to 4049adc Compare March 31, 2026 12:20
cpcloud and others added 7 commits March 31, 2026 08:21
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>
@cpcloud cpcloud force-pushed the worktree-mutable-humming-swing branch from 4049adc to 0655e17 Compare March 31, 2026 12:25
@cpcloud cpcloud merged commit 7ec5e80 into micasa-dev:main Mar 31, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request ux User experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(ui): format phone numbers for display

1 participant