From edadf3944577416cb9dd915a1666c854c06c7805 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Fri, 10 Apr 2026 10:09:26 +0200 Subject: [PATCH] fix(pitch-admin): render JSONB arrays as inline table editors Arrays of objects (funding_schedule, founder_salary_schedule, etc.) now render as editable tables with per-field inputs, add/remove row buttons, instead of a raw JSON string in a single text input. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../financial-model/[scenarioId]/page.tsx | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/pitch-deck/app/pitch-admin/(authed)/financial-model/[scenarioId]/page.tsx b/pitch-deck/app/pitch-admin/(authed)/financial-model/[scenarioId]/page.tsx index 24ddda6..cc16f93 100644 --- a/pitch-deck/app/pitch-admin/(authed)/financial-model/[scenarioId]/page.tsx +++ b/pitch-deck/app/pitch-admin/(authed)/financial-model/[scenarioId]/page.tsx @@ -128,6 +128,92 @@ export default function EditScenarioPage() {
{items.map(a => { const isEdited = edits[a.id] !== undefined + // Detect arrays of objects for structured editing + const isObjectArray = Array.isArray(a.value) && a.value.length > 0 && typeof a.value[0] === 'object' && a.value[0] !== null + + if (isObjectArray) { + const rows = isEdited ? (JSON.parse(edits[a.id]) as Record[]) : (a.value as Record[]) + const cols = Object.keys(rows[0] || {}) + + return ( +
+
+
+ {a.label_en || a.label_de} + {a.key} +
+
+ + {isEdited && ( + + )} +
+
+ + + + {cols.map(c => ( + + ))} + + + + {rows.map((row, ri) => ( + + {cols.map(c => ( + + ))} + + + ))} + +
{c} +
+ { + const updated = rows.map((r, i) => { + if (i !== ri) return r + const val = typeof r[c] === 'number' ? Number(e.target.value) || 0 : e.target.value + return { ...r, [c]: val } + }) + setEdit(a.id, JSON.stringify(updated)) + }} + className="w-full bg-transparent border-b border-transparent hover:border-white/10 focus:border-indigo-500/50 text-white font-mono py-0.5 focus:outline-none" + /> + + +
+
+ ) + } + const currentValue = isEdited ? edits[a.id] : typeof a.value === 'object'