chore(i18n): drop legacy free-text country/nationality columns

Test-data only — no production migration needed (per earlier decision).
Schema is now ISO-only; readers convert ISO codes to localized names where
human-readable output is required (EOI documents, invoices, portal).

Migration 0016 drops:
  - clients.nationality
  - companies.incorporation_country
  - client_addresses.{state_province, country}
  - company_addresses.{state_province, country}

Code paths that previously read free-text values now read the ISO column
and pass through `getCountryName()` / `getSubdivisionName()` for rendering.
Document templates ({{client.nationality}}), portal client view, EOI/
reservation-agreement contexts, and invoice billing addresses all updated.

Public yacht-interest endpoint (/api/public/interests) drops the legacy
fields from its insert path and writes ISO codes only. The Zod validators
no longer accept the legacy fields — older website builds posting raw
'incorporationCountry' / 'country' / 'stateProvince' will get 400s.
Server-side phone normalization is unchanged.

Seed data updated to use ISO codes (GB/FR/ES/GR/SE/IT/GH/MC/PA), spread
across continents to keep test fixtures realistic.

Test assertions updated to match the new render shape (e.g.
'United States' not 'US', 'California' not 'CA').

Vitest: 741 -> 741 (unchanged count; assertions updated, no new tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matt Ciaccio
2026-04-28 19:00:57 +02:00
parent 31fa3d08ec
commit 27cdbcc695
30 changed files with 9959 additions and 104 deletions

View File

@@ -14,11 +14,12 @@ import {
} from '@/components/ui/dropdown-menu';
import { Badge } from '@/components/ui/badge';
import { TagBadge } from '@/components/shared/tag-badge';
import { getCountryName } from '@/lib/i18n/countries';
export interface ClientRow {
id: string;
fullName: string;
nationality: string | null;
nationalityIso: string | null;
source: string | null;
archivedAt: string | null;
createdAt: string;
@@ -78,11 +79,14 @@ export function getClientColumns({
},
{
id: 'nationality',
accessorKey: 'nationality',
accessorKey: 'nationalityIso',
header: 'Nationality',
cell: ({ getValue }) => (
<span className="text-muted-foreground">{(getValue() as string | null) ?? '—'}</span>
),
cell: ({ getValue }) => {
const iso = getValue() as string | null;
return (
<span className="text-muted-foreground">{iso ? getCountryName(iso, 'en') : '—'}</span>
);
},
},
{
id: 'source',

View File

@@ -12,7 +12,7 @@ interface ClientData {
id: string;
portId: string;
fullName: string;
nationality: string | null;
nationalityIso: string | null;
preferredContactMethod: string | null;
preferredLanguage: string | null;
timezone: string | null;

View File

@@ -34,7 +34,6 @@ interface ClientFormProps {
client?: {
id: string;
fullName: string;
nationality?: string | null;
nationalityIso?: string | null;
preferredContactMethod?: string | null;
preferredLanguage?: string | null;
@@ -83,7 +82,6 @@ export function ClientForm({ open, onOpenChange, client }: ClientFormProps) {
if (client && open) {
reset({
fullName: client.fullName,
nationality: client.nationality ?? undefined,
nationalityIso: client.nationalityIso ?? undefined,
preferredContactMethod:
(client.preferredContactMethod as CreateClientInput['preferredContactMethod']) ??

View File

@@ -19,7 +19,6 @@ export interface CompanyRow {
legalName: string | null;
taxId: string | null;
registrationNumber: string | null;
incorporationCountry: string | null;
incorporationCountryIso: string | null;
incorporationSubdivisionIso: string | null;
incorporationDate: string | null;

View File

@@ -20,7 +20,6 @@ interface CompanyDetailHeaderCompany {
legalName: string | null;
taxId: string | null;
registrationNumber: string | null;
incorporationCountry: string | null;
incorporationCountryIso: string | null;
incorporationSubdivisionIso: string | null;
incorporationDate: string | null;
@@ -132,7 +131,6 @@ export function CompanyDetailHeader({ company }: CompanyDetailHeaderProps) {
legalName: company.legalName,
taxId: company.taxId,
registrationNumber: company.registrationNumber,
incorporationCountry: company.incorporationCountry,
incorporationCountryIso: company.incorporationCountryIso,
incorporationSubdivisionIso: company.incorporationSubdivisionIso,
incorporationDate: company.incorporationDate,

View File

@@ -16,7 +16,6 @@ export interface CompanyData {
legalName: string | null;
taxId: string | null;
registrationNumber: string | null;
incorporationCountry: string | null;
incorporationCountryIso: string | null;
incorporationSubdivisionIso: string | null;
incorporationDate: string | null;

View File

@@ -41,7 +41,6 @@ interface CompanyFormProps {
legalName: string | null;
taxId: string | null;
registrationNumber: string | null;
incorporationCountry: string | null;
incorporationCountryIso: string | null;
incorporationSubdivisionIso: string | null;
incorporationDate: string | null;
@@ -83,7 +82,6 @@ export function CompanyForm({ open, onOpenChange, company }: CompanyFormProps) {
legalName: company.legalName ?? undefined,
taxId: company.taxId ?? undefined,
registrationNumber: company.registrationNumber ?? undefined,
incorporationCountry: company.incorporationCountry ?? undefined,
incorporationCountryIso: company.incorporationCountryIso ?? undefined,
incorporationSubdivisionIso: company.incorporationSubdivisionIso ?? undefined,
incorporationDate: company.incorporationDate

View File

@@ -145,7 +145,6 @@ export function CompanyList() {
legalName: editCompany.legalName,
taxId: editCompany.taxId,
registrationNumber: editCompany.registrationNumber,
incorporationCountry: editCompany.incorporationCountry,
incorporationCountryIso: editCompany.incorporationCountryIso,
incorporationSubdivisionIso: editCompany.incorporationSubdivisionIso,
incorporationDate: editCompany.incorporationDate,

View File

@@ -38,7 +38,6 @@ interface CompanyTabsCompany {
legalName: string | null;
taxId: string | null;
registrationNumber: string | null;
incorporationCountry: string | null;
incorporationCountryIso: string | null;
incorporationSubdivisionIso: string | null;
incorporationDate: string | null;