From f168971e25c0cd30aa53665d49c04dd9831b23d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simon=20Pocrnji=C4=8D?=
Date: Sun, 21 Jun 2026 21:47:51 +0200
Subject: [PATCH] JSON parse normalize function
---
resources/js/Pages/Phone/Case/Index.vue | 38 +++++++++++++++++++++++--
1 file changed, 35 insertions(+), 3 deletions(-)
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;
+}
@@ -447,10 +479,10 @@ const clientSummary = computed(() => {
{{ textTrancate(c.description, 50, false) }}
-
+
@@ -459,7 +491,7 @@ const clientSummary = computed(() => {