'use client' import { usePublicationToggle } from '@/components/campaign/shared/usePublicationToggle' import { SpeechCutStatusBadge } from '@/components/campaign/speech/SpeechCutStatusBadge' import { Alert, AlertDescription } from '@/components/ui/Alert' import { AlertDialog, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/AlertDialog' import { Button } from '@/components/ui/button' import { Spinner } from '@/components/ui/Spinner' import type { SpeechCutStatus } from '@/lib/speechCut' type SpeechCutPublicationPanelProps = { cutId: number status: SpeechCutStatus } const UNPUBLISH_WARNING = 'O link público deixa de funcionar para quem já recebeu. Você pode publicar de novo quando quiser.' /** * C168 — the kill switch on the detail page. Publishing restores the same * public link; unpublishing asks for confirmation with the product copy and * takes it off the air. A cut without a stored file cannot be published. */ export const SpeechCutPublicationPanel = ({ cutId, status }: SpeechCutPublicationPanelProps) => { const { submitting, error, setPublished } = usePublicationToggle({ href: `/campanha/comunicacao/acervo/cortes/${cutId}/publicacao`, buildBody: (published) => ({ cutId, published }), }) return (

Publicação

{status === 'published' ? ( <>

{UNPUBLISH_WARNING}

Despublicar este corte? {UNPUBLISH_WARNING} Cancelar ) : null} {status === 'unpublished' ? ( <>

Despublicado, o link público não responde. Publique para reativar o mesmo link.

) : null} {status === 'processing' ? (

O corte ainda está sendo preparado. Assim que o arquivo ficar pronto, publique por aqui.

) : null} {status === 'failed' ? (

Não foi possível preparar o arquivo. Tente novamente sem refazer o corte.

) : null} {error ? ( {error} ) : null}
) }