'use client'; import React, { useEffect, useMemo, useState } from 'react'; import { ArrowRight, CheckCircle2, ExternalLink, ImageIcon, Palette, Type, } from 'lucide-react'; import { Surface } from '@/components/ui'; import { primaryLogo, type Brandbook, type BrandbookSectionId, } from '@/lib/brandbook'; function LogoPreview({ assetFileId, alt, }: { assetFileId: string; alt: string; }) { const [url, setUrl] = useState(null); useEffect(() => { let cancelled = false; (async () => { const r = await fetch( `/api/assets/download?id=${encodeURIComponent(assetFileId)}` ); const j = await r.json(); if (!cancelled && r.ok && j.url) setUrl(j.url); })(); return () => { cancelled = true; }; }, [assetFileId]); if (!url) { return (
Cargando logo…
); } return ( // eslint-disable-next-line @next/next/no-img-element {alt} ); } function PillRow({ title, items, emptyHint, accent = 'brand', }: { title: string; items: string[]; emptyHint: string; accent?: 'brand' | 'sky' | 'violet' | 'amber'; }) { const tone = accent === 'sky' ? 'border-sky-200 bg-sky-50 text-sky-900' : accent === 'violet' ? 'border-violet-200 bg-violet-50 text-violet-900' : accent === 'amber' ? 'border-amber-200 bg-amber-50 text-amber-900' : 'border-brand-200 bg-brand-50 text-brand-900'; return (

{title}

{items.length ? (
{items.map((item) => ( {item} ))}
) : (

{emptyHint}

)}
); } function websiteFromBook(book: Brandbook): string | null { const candidates = [ book.website, book.channel_handles?.blog, book.channels?.blog, ]; for (const c of candidates) { const raw = String(c || '').trim(); if (!raw) continue; if (/^https?:\/\//i.test(raw)) return raw; if (raw.includes('.') && !raw.startsWith('@')) { return `https://${raw.replace(/^\/+/, '')}`; } } return null; } export default function BrandOverview({ book, tenantLabel, score, missing, onEditSection, onContinueEdit, embedded = false, }: { book: Brandbook; tenantLabel: string; score: number; missing: string[]; onEditSection: (id: BrandbookSectionId) => void; onContinueEdit: () => void; /** Cuando va dentro del panel de Zona de marca (sin card exterior). */ embedded?: boolean; }) { const logo = primaryLogo(book); const site = websiteFromBook(book); const fonts = book.fonts_kit.slice(0, 4); const colors = book.colors.slice(0, 8); const values = book.values.filter(Boolean).slice(0, 8); const aesthetic = [ ...book.personality, book.photography_style, book.illustration_style, book.visual_notes, ] .flatMap((x) => String(x || '') .split(/[,;·|/]/) .map((s) => s.trim()) .filter(Boolean) ) .filter((v, i, arr) => arr.indexOf(v) === i) .slice(0, 8); const tonePills = [ book.tone, ...book.voice_do.slice(0, 3), ...book.personality.slice(0, 2), ] .map((s) => String(s || '').trim()) .filter(Boolean) .filter((v, i, arr) => arr.indexOf(v) === i) .slice(0, 6); const overviewText = useMemo(() => { return ( book.elevator_pitch || book.brand_promise || book.positioning || book.mission || '' ).trim(); }, [book]); const header = (

Brand Overview

Perfil de marca

{!embedded ? (

Resumen visual del brandbook · editable por secciones

) : null}
); const content = (
{/* Identity */}

Identidad

{book.brand_name || tenantLabel}

{site ? ( {site.replace(/^https?:\/\//i, '')} ) : ( )}
{logo ? ( ) : ( )}

Tipografías

{fonts.length ? (
{fonts.map((f) => (

Aa

{f.family}

{f.role}

))}
) : ( )}

Colores

{colors.length ? (
{colors.map((c) => (
{c.hex}
))}
) : ( )}
{/* Tagline */}

Tagline

{book.tagline ? (

{book.tagline}

) : ( )}
{/* Business overview */}

Business overview

{overviewText ? ( overviewText ) : ( )}
{/* Copy real ads / RRSS */}

Copy real (Meta / Google / RRSS)

{(book.winning_hooks || []).length || (book.ads_usps || []).length || (book.ads_ctas || []).length ? (
{(book.ads_ctas || []).length ? (

CTAs:{' '} {(book.ads_ctas || []).slice(0, 6).join(' · ')}

) : null} {(book.ads_usps || []).length ? ( ) : null} {(book.winning_hooks || []).length ? (
    {(book.winning_hooks || []).slice(0, 5).map((h) => (
  • {h}
  • ))}
) : null}
) : ( )}
{/* LinkedIn B2B & Thought Leadership */}

Estrategia LinkedIn B2B & Thought Leadership

{(book.linkedin_themes || []).length || (book.thought_leadership || []).length || (book.case_study_angles || []).length ? (
{(book.linkedin_themes || []).length ? ( ) : null} {(book.thought_leadership || []).length ? (

Posicionamiento de Autoridad / Thought Leadership

    {(book.thought_leadership || []).slice(0, 3).map((tl, i) => (
  • {tl}
  • ))}
) : null} {(book.buyer_roles || []).length ? (

Buyer Roles B2B

{(book.buyer_roles || []).slice(0, 4).join(' · ')}

) : null} {(book.case_study_angles || []).length ? (

Casos de estudio B2B observados

    {(book.case_study_angles || []).slice(0, 3).map((cs, i) => (
  • {cs}
  • ))}
) : null} {(book.linkedin_cta || []).length ? (

CTAs de baja fricción:{' '} {(book.linkedin_cta || []).slice(0, 3).join(' · ')}

) : null}
) : ( )}
); const footer = (

{score}% completo

{score >= 100 ? ( Kit sólido ) : missing[0] ? (

Falta: {missing.slice(0, 2).join(' · ')}

) : null}
); if (embedded) { return (
{header} {content} {footer}
); } return (
{header} {content} {footer}
); }