fix: corregir parseBrandbook para deserializar strings de documents, restaurar paneles y sincronización bidireccional total entre Zona de Marca y Creatividades Ads
This commit is contained in:
@@ -983,8 +983,19 @@ export function seedBrandbook(slug: string, label: string): Brandbook {
|
||||
}
|
||||
|
||||
export function parseBrandbook(raw: unknown): Brandbook | null {
|
||||
if (!raw || typeof raw !== 'object') return null;
|
||||
const o = raw as Record<string, unknown>;
|
||||
if (!raw) return null;
|
||||
let o: any = raw;
|
||||
if (typeof raw === 'string') {
|
||||
try {
|
||||
o = JSON.parse(raw);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (!o || typeof o !== 'object') return null;
|
||||
if (o.content && (typeof o.content === 'object' || typeof o.content === 'string')) {
|
||||
return parseBrandbook(o.content);
|
||||
}
|
||||
const ver = Number(o.version);
|
||||
if (
|
||||
ver !== 1 &&
|
||||
@@ -994,11 +1005,13 @@ export function parseBrandbook(raw: unknown): Brandbook | null {
|
||||
!('tone' in o) &&
|
||||
!('pillars_rrss' in o) &&
|
||||
!('mission' in o) &&
|
||||
!('kit_assets' in o)
|
||||
!('kit_assets' in o) &&
|
||||
!('b2b_offering' in o) &&
|
||||
!('identity' in o)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const partial = raw as Partial<Brandbook>;
|
||||
const partial = o as Partial<Brandbook>;
|
||||
const empty = emptyBrandbook(String(partial.brand_name || ''));
|
||||
const colors = migrateColors(partial, empty);
|
||||
const fonts_kit = migrateFonts(partial, empty);
|
||||
|
||||
Reference in New Issue
Block a user