diff --git a/src/components/BrandZone.tsx b/src/components/BrandZone.tsx index c3dc833..a43a04c 100644 --- a/src/components/BrandZone.tsx +++ b/src/components/BrandZone.tsx @@ -35,6 +35,7 @@ import type { B2BAnalysisResult } from '@/lib/b2b-analyzer'; import { ASSET_KIND_LABELS, emptyBrandbook, + finalizeLinesList, linesToList, listToLines, newId, @@ -278,11 +279,23 @@ export default function BrandZone({ setErr(null); setOkMsg(null); try { + // Trim list fields only on save — mid-edit we keep spaces so phrases work. + const cleaned = { ...book } as Brandbook & Record; + for (const key of Object.keys(cleaned)) { + const v = cleaned[key]; + if ( + Array.isArray(v) && + v.length >= 0 && + v.every((x) => typeof x === 'string') + ) { + cleaned[key] = finalizeLinesList(v as string[]); + } + } const query = tenantId ? `?tenant_id=${encodeURIComponent(tenantId)}` : ''; const r = await fetch(`/api/brandbook${query}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ brandbook: book, tenant_id: tenantId }), + body: JSON.stringify({ brandbook: cleaned, tenant_id: tenantId }), }); const j = await r.json(); if (!r.ok) throw new Error(j.error || 'No se pudo guardar'); @@ -1061,6 +1074,7 @@ export default function BrandZone({