PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.10
Yatra – Travel Booking & Tour Operator Software v3.0.10
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / resources / js / components / common / PhoneDisplay.tsx

PhoneDisplay.tsx in Yatra – Travel Booking & Tour Operator Software 3.0.10, at resources/js/components/common/PhoneDisplay.tsx

51 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Renders a stored phone value as flag + readable number in admin views.
3 * International values ("+9779806015400") show the detected country flag and a
4 * spaced "+977 9806015400"; legacy national-only values render as plain text
5 * with no flag (never reinterpreted).
6 */
7 import React from "react";
8 import { detectPhoneCountry, flagUrl, formatPhone } from "../../lib/phone";
9
10 interface PhoneDisplayProps {
11 value?: string | null;
12 className?: string;
13 }
14
15 export const PhoneDisplay: React.FC<PhoneDisplayProps> = ({
16 value,
17 className,
18 }) => {
19 const raw = (value || "").trim();
20 if (!raw) return null;
21
22 const detected = detectPhoneCountry(raw);
23 const url = detected ? flagUrl(detected.iso) : "";
24
25 return (
26 <span
27 className={className}
28 style={{ display: "inline-flex", alignItems: "center", gap: 6 }}
29 >
30 {url && (
31 <img
32 src={url}
33 alt={detected ? detected.iso : ""}
34 width={18}
35 height={13}
36 loading="lazy"
37 style={{
38 borderRadius: 2,
39 objectFit: "cover",
40 boxShadow: "0 0 0 1px rgba(0,0,0,0.08)",
41 flex: "0 0 auto",
42 }}
43 />
44 )}
45 <span>{detected ? formatPhone(raw) : raw}</span>
46 </span>
47 );
48 };
49
50 export default PhoneDisplay;
51