diff --git a/resources/js/Pages/Phone/Case/Index.vue b/resources/js/Pages/Phone/Case/Index.vue index 558e6f4..6ca54db 100644 --- a/resources/js/Pages/Phone/Case/Index.vue +++ b/resources/js/Pages/Phone/Case/Index.vue @@ -302,6 +302,38 @@ const clientSummary = computed(() => { trr: p.trr || p.bank_account || null, }; }); + +// Normalise contract meta: handles JSON strings and PHP numeric-keyed wrappers. +// When a top-level value has no {title, value, type} shape but is itself a plain +// object, we flatten one level so the real meta entries become the top-level keys. +function normalizeMeta(meta) { + if (!meta) return {}; + let obj = meta; + if (typeof obj === "string") { + try { + obj = JSON.parse(obj); + } catch { + return {}; + } + } + if (typeof obj !== "object" || Array.isArray(obj)) return {}; + const result = {}; + for (const [key, val] of Object.entries(obj)) { + if ( + val && + typeof val === "object" && + !Array.isArray(val) && + !("value" in val) && + !("title" in val) + ) { + // Nested meta map — flatten it one level + Object.assign(result, val); + } else { + result[key] = val; + } + } + return result; +}