Format phone object in detail view (phone_with_dial_code)
This commit is contained in:
parent
d0016bac0b
commit
c6a32de2ba
@ -129,7 +129,7 @@ export default function DetailViewPanel({ viewId, instanceId }: Props) {
|
|||||||
const stateName = String(data.current_state_name ?? "");
|
const stateName = String(data.current_state_name ?? "");
|
||||||
const sc = STATUS[stateName] ?? DS;
|
const sc = STATUS[stateName] ?? DS;
|
||||||
|
|
||||||
const phone = String(data.customer_phone ?? "");
|
const phone = fmtPhone(data.customer_phone);
|
||||||
const model = String(data.model_interest ?? "");
|
const model = String(data.model_interest ?? "");
|
||||||
|
|
||||||
const leftGroups = [
|
const leftGroups = [
|
||||||
@ -353,6 +353,10 @@ function fmtLabel(label: string): string {
|
|||||||
|
|
||||||
function fmtVal(val: unknown, type: string, key: string): string {
|
function fmtVal(val: unknown, type: string, key: string): string {
|
||||||
if (val == null || val === "") return "—";
|
if (val == null || val === "") return "—";
|
||||||
|
if (type === "phone" && typeof val === "object") {
|
||||||
|
const p = val as { phone_with_dial_code?: string; phone?: string; dial_code?: string };
|
||||||
|
return p.phone_with_dial_code || (p.dial_code && p.phone ? `${p.dial_code}${p.phone}` : p.phone || "—");
|
||||||
|
}
|
||||||
if (type === "number") {
|
if (type === "number") {
|
||||||
const n = Number(val);
|
const n = Number(val);
|
||||||
if (["amount","tax","price","cost"].some(x => key.toLowerCase().includes(x))) return fmtCurrency(n);
|
if (["amount","tax","price","cost"].some(x => key.toLowerCase().includes(x))) return fmtCurrency(n);
|
||||||
@ -370,3 +374,12 @@ function fmtDate(val: string): string {
|
|||||||
try { return new Date(val).toLocaleDateString("en-IN", { day: "2-digit", month: "short", year: "numeric" }); }
|
try { return new Date(val).toLocaleDateString("en-IN", { day: "2-digit", month: "short", year: "numeric" }); }
|
||||||
catch { return val; }
|
catch { return val; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fmtPhone(val: unknown): string {
|
||||||
|
if (val == null || val === "") return "";
|
||||||
|
if (typeof val === "object") {
|
||||||
|
const p = val as { phone_with_dial_code?: string; phone?: string; dial_code?: string };
|
||||||
|
return p.phone_with_dial_code || (p.dial_code && p.phone ? `${p.dial_code}${p.phone}` : p.phone || "");
|
||||||
|
}
|
||||||
|
return String(val);
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user