'use client' import { useEffect, useRef, useState } from 'react' import { sendContentPieceEvent } from '@/lib/contentEvents' import { contentPieceAspectClass, contentPieceMediaKind, type ContentPiecePublicItem, } from '@/lib/contentPieceCatalog' import { cn } from '@/lib/utils' import { ContentPieceDownloadLink, ContentPieceShareButton } from './ContentPieceActions' import { ContentPieceMedia } from './ContentPieceMedia' import { ContentPieceShareSheet } from './ContentPieceShareSheet' import { CONTENT_PIECE_TAG } from './contentPieceClasses' type Fact = { label: string; value: string } const originOrDurationFact = (item: ContentPiecePublicItem): Fact | null => { if (item.isLink) return { label: 'Origem', value: item.originLabel } if (item.durationLabel) return { label: 'Duração', value: item.durationLabel } return null } /** * S27 — the piece page body (artefato: cenas 04/07): the asset on the left * (play on demand, photo preview, platform placeholder for a link piece), the * title/description/facts and the same two actions of the card. The share * sheet is the same component, so the message is identical everywhere. */ export const ContentPieceDetail = ({ item }: { item: ContentPiecePublicItem }) => { const [playing, setPlaying] = useState(false) const [sharing, setSharing] = useState(false) // C213 — one open is one anonymous counter. The ref keeps the dev // StrictMode's double effect from counting twice, and a client-side return // to the page mounts a fresh component (a real second open). const trackedOpen = useRef(false) useEffect(() => { if (trackedOpen.current) return trackedOpen.current = true sendContentPieceEvent('abertura', item.slug) }, [item.slug]) const facts = [ item.topicLabels.length > 0 ? { label: 'Tema', value: item.topicLabels.join(', ') } : null, item.cityLabel || item.regionLabel ? { label: 'Local', value: item.cityLabel ?? item.regionLabel ?? '' } : null, originOrDurationFact(item), item.pieceDateLabel ? { label: 'Data', value: item.pieceDateLabel } : null, ].filter((fact): fact is Fact => fact !== null) return ( <> {/* S45 — the piece page keeps the card's promise: the 360px media column (artefato cena 05) and the frame of the type — Reel 9:16, photo 4:5, wide kinds 16:9 — with the media whole, never cropped. */}
setPlaying((current) => !current)} onEnded={() => setPlaying(false)} variant="detail" className={contentPieceAspectClass(contentPieceMediaKind(item)) ?? 'aspect-video'} />
{item.isLink ? item.originLabel : item.typeLabel}

{item.title}

{item.description ? (

{item.description}

) : null} {facts.length > 0 ? (
{facts.map((fact) => (
{fact.label}
{fact.value}
))}
) : null}
setSharing(true)} />
{item.isLink ? (

O compartilhamento usa o link da publicação no {item.originLabel}.

) : null}
{sharing ? setSharing(false)} /> : null} ) }