diff --git a/src/components/AdCreativesGallery.tsx b/src/components/AdCreativesGallery.tsx index 428b795..a83e288 100644 --- a/src/components/AdCreativesGallery.tsx +++ b/src/components/AdCreativesGallery.tsx @@ -179,6 +179,42 @@ function formatThumbs(ad: AdCreativeCard): { url: string; aspect: CreativeAspect return out; } +function CopyList({ + label, + items, + strong, + muted, +}: { + label: string; + items: string[]; + strong?: boolean; + muted?: boolean; +}) { + return ( +
+

+ {label} +

+ +
+ ); +} + function MiniKpi({ label, value }: { label: string; value: string }) { return (
@@ -363,6 +399,13 @@ function CreativeCard({ const headlines = adHeadlines(ad); const bodies = adBodies(ad); const linkDescs = adLinkDescriptions(ad); + const longTitles = ad.longHeadlines || []; + const googleDescs = + ad.platform === 'google' + ? ad.descriptions?.length + ? ad.descriptions + : bodies + : []; const assets = adAssets(ad); const extraCount = Math.max(0, assets.length - 1); const pmaxFormats = formatThumbs(ad); @@ -409,9 +452,9 @@ function CreativeCard({ {h}

))} - {bodies[0] ? ( + {googleDescs[0] ? (

- {bodies[0]} + {googleDescs[0]}

) : null}
@@ -510,53 +553,52 @@ function CreativeCard({

Conjunto: {ad.adsetName}

) : null} - {(headlines.length > 0 || bodies.length > 0 || linkDescs.length > 0) && ( + {(headlines.length > 0 || + longTitles.length > 0 || + bodies.length > 0 || + linkDescs.length > 0 || + googleDescs.length > 0) && (
- {headlines.length > 0 ? ( -
-

- Titulares ({headlines.length}) -

- -
- ) : null} - {bodies.length > 0 ? ( -
-

- Textos ({bodies.length}) -

- -
- ) : null} - {linkDescs.length > 0 ? ( -
-

- Descripción -

- -
- ) : null} + {ad.platform === 'google' ? ( + <> + {headlines.length > 0 ? ( + + ) : null} + {longTitles.length > 0 ? ( + + ) : null} + {googleDescs.length > 0 ? ( + + ) : null} + + ) : ( + <> + {headlines.length > 0 ? ( + + ) : null} + {bodies.length > 0 ? ( + + ) : null} + {linkDescs.length > 0 ? ( + + ) : null} + + )} {ad.cta ? (

CTA · {ad.cta} @@ -589,6 +631,13 @@ export function CreativeZoomModal({ const bodies = adBodies(ad); const linkDescs = adLinkDescriptions(ad); const longH = ad.longHeadlines || []; + const googleDescs = + ad.platform === 'google' + ? ad.descriptions?.length + ? ad.descriptions + : bodies + : []; + const isGoogle = ad.platform === 'google'; const assets = adAssets(ad); const images = assets.filter((a) => a.kind === 'image' || a.kind === 'logo'); const videos = assets.filter((a) => a.kind === 'youtube' || a.kind === 'video'); @@ -802,7 +851,7 @@ export function CreativeZoomModal({ {headlines.length > 0 ? (

- Titulares ({headlines.length}) + {isGoogle ? 'Títulos' : 'Titulares'} ({headlines.length})

    {headlines.map((h) => ( @@ -820,7 +869,7 @@ export function CreativeZoomModal({ {longH.length > 0 ? (

    - Titulares largos ({longH.length}) + Títulos largos ({longH.length})

      {longH.map((h) => ( @@ -835,7 +884,25 @@ export function CreativeZoomModal({
    ) : null} - {bodies.length > 0 ? ( + {isGoogle && googleDescs.length > 0 ? ( +
    +

    + Descripciones ({googleDescs.length}) +

    +
      + {googleDescs.map((b) => ( +
    • + {b} +
    • + ))} +
    +
    + ) : null} + + {!isGoogle && bodies.length > 0 ? (

    Textos ({bodies.length}) @@ -853,7 +920,7 @@ export function CreativeZoomModal({

    ) : null} - {linkDescs.length > 0 ? ( + {!isGoogle && linkDescs.length > 0 ? (

    Descripción diff --git a/src/lib/ad-creatives-google.ts b/src/lib/ad-creatives-google.ts index 3614ba1..6bf87f7 100644 --- a/src/lib/ad-creatives-google.ts +++ b/src/lib/ad-creatives-google.ts @@ -138,6 +138,14 @@ function enumName(v?: string): string { return (v || '').replace(/^[A-Z0-9]+_/, '') || str(v); } +/** Do not strip LONG_HEADLINE → HEADLINE (enumName would). */ +function assetFieldType(v?: string): string { + return str(v) + .toUpperCase() + .replace(/^ASSET_FIELD_TYPE_/, '') + .replace(/^ASSETFIELDTYPE_/, ''); +} + function uniq(arr: string[]): string[] { return [...new Set(arr.filter(Boolean))]; } @@ -600,7 +608,7 @@ WHERE ad_group_ad.status != 'REMOVED' const adId = str(row.adGroupAd?.ad?.id); if (!adId) continue; const list = assetsByAdId.get(adId) || []; - const ft = enumName(row.adGroupAdAssetView?.fieldType).toUpperCase(); + const ft = assetFieldType(row.adGroupAdAssetView?.fieldType); const img = str(row.asset?.imageAsset?.fullSize?.url); const w = n(row.asset?.imageAsset?.fullSize?.widthPixels) || undefined; const h = n(row.asset?.imageAsset?.fullSize?.heightPixels) || undefined; @@ -698,7 +706,7 @@ WHERE ad_group_ad.status != 'REMOVED' }; agMap.set(agid, entry); } - const ft = enumName(row.assetGroupAsset?.fieldType).toUpperCase(); + const ft = assetFieldType(row.assetGroupAsset?.fieldType); const text = str(row.asset?.textAsset?.text); const img = str(row.asset?.imageAsset?.fullSize?.url); const imgW = n(row.asset?.imageAsset?.fullSize?.widthPixels) || undefined; @@ -804,12 +812,12 @@ WHERE ad_group_ad.status != 'REMOVED' }), thumbnailUrl: preview, imageUrl: preview, - headline: [...headlines, ...longHeadlines].join('\n'), + headline: headlines.join('\n'), primaryText: descriptions.join('\n'), headlines, - bodies: descriptions, + bodies: [], longHeadlines, - descriptions: [], + descriptions, sitelinks, callouts, snippets, @@ -914,12 +922,12 @@ WHERE ad_group_ad.status != 'REMOVED' }), thumbnailUrl: preview, imageUrl: preview, - headline: [...headlines, ...longHeadlines].join('\n'), + headline: headlines.join('\n'), primaryText: descriptions.join('\n'), headlines, - bodies: descriptions, + bodies: [], longHeadlines, - descriptions: [], + descriptions, assets, linkUrl: (ad?.finalUrls || []).map(str).filter(Boolean)[0], cta: str(rda?.callToActionText) || undefined, @@ -928,7 +936,7 @@ WHERE ad_group_ad.status != 'REMOVED' youtubeId: firstYt, }); if (paths.length) { - cards[cards.length - 1].bodies = [ + cards[cards.length - 1].descriptions = [ ...descriptions, `Path: /${paths.join('/')}`, ];