/** * Renders a stored phone value as flag + readable number in admin views. * International values ("+9779806015400") show the detected country flag and a * spaced "+977 9806015400"; legacy national-only values render as plain text * with no flag (never reinterpreted). */ import React from "react"; import { detectPhoneCountry, flagUrl, formatPhone } from "../../lib/phone"; interface PhoneDisplayProps { value?: string | null; className?: string; } export const PhoneDisplay: React.FC = ({ value, className, }) => { const raw = (value || "").trim(); if (!raw) return null; const detected = detectPhoneCountry(raw); const url = detected ? flagUrl(detected.iso) : ""; return ( {url && ( {detected )} {detected ? formatPhone(raw) : raw} ); }; export default PhoneDisplay;