import type { ReactNode } from 'react' import { CONTENT_PIECE_CIRCULATION_DETAIL_INTRO, CONTENT_PIECE_CIRCULATION_HISTORY_BODY, CONTENT_PIECE_CIRCULATION_HISTORY_TITLE, CONTENT_PIECE_CIRCULATION_METRICS, CONTENT_PIECE_CIRCULATION_NEVER_PUBLISHED_BODY, CONTENT_PIECE_CIRCULATION_NEVER_PUBLISHED_TITLE, CONTENT_PIECE_CIRCULATION_PRIVACY, CONTENT_PIECE_CIRCULATION_READING, CONTENT_PIECE_CIRCULATION_UNAVAILABLE_BODY, CONTENT_PIECE_CIRCULATION_UNAVAILABLE_TITLE, CONTENT_PIECE_CIRCULATION_UNAVAILABLE_VALUE, CONTENT_PIECE_CIRCULATION_UNAVAILABLE_VALUE_LABEL, isContentPieceCirculationEmpty, showsContentPieceCirculationHistory, type ContentPieceCirculationMetric, type ContentPieceCirculationView, } from '@/lib/contentPieceCirculation' import { cn } from '@/lib/utils' /** * C213 — the "Circulação" block of the piece ficha (approved design scenes * 02/05/06/07): four absolute counters in the ported responsive grid, then the * honest state — never published, historical after unpublishing, or counting * unavailable — then "Leitura:" (only when there are counters to compare) and * the privacy line. The form follows below. */ const noteClasses = 'rounded-lg bg-muted text-muted-foreground' const notePaddingClasses = 'p-3 text-xs leading-5 sm:p-4 sm:text-sm sm:leading-6' /** Cells 2–4 carry the grid's separators (design's port contract). */ const cellDividerClasses = [ undefined, 'sm:border-l', 'sm:border-t lg:border-l lg:border-t-0', 'sm:border-l sm:border-t lg:border-t-0', ] as const const metricStrip = ( renderValue: (metric: ContentPieceCirculationMetric) => ReactNode, ): ReactNode => (
{CONTENT_PIECE_CIRCULATION_METRICS.map((metric, index) => (
{metric.detailLabel}
{renderValue(metric)}
))}
) const unavailableStrip = metricStrip((metric) => (
)) const countersStrip = (view: Extract) => metricStrip((metric) => (
{view.counts[metric.key]}
)) export const ContentPieceCirculationPanel = ({ circulation, isPublished, }: { circulation: ContentPieceCirculationView isPublished: boolean }) => { const hasCounters = circulation.state === 'data' && !isContentPieceCirculationEmpty(circulation.counts) return (

Circulação

{CONTENT_PIECE_CIRCULATION_DETAIL_INTRO}

{circulation.state === 'unavailable' ? ( <> {unavailableStrip}

{CONTENT_PIECE_CIRCULATION_UNAVAILABLE_TITLE}{' '} {CONTENT_PIECE_CIRCULATION_UNAVAILABLE_BODY}

) : circulation.state === 'neverPublished' ? (

{CONTENT_PIECE_CIRCULATION_NEVER_PUBLISHED_TITLE}

{CONTENT_PIECE_CIRCULATION_NEVER_PUBLISHED_BODY}

) : ( <> {countersStrip(circulation)} {showsContentPieceCirculationHistory(circulation, isPublished) ? (

{CONTENT_PIECE_CIRCULATION_HISTORY_TITLE}{' '} {CONTENT_PIECE_CIRCULATION_HISTORY_BODY}

) : null} )} {hasCounters ? ( ) : null}

Privacidade:{' '} {CONTENT_PIECE_CIRCULATION_PRIVACY}

) }