'use client' import { CircleAlertIcon } from 'lucide-react' import { useRouter } from 'next/navigation' import { useState } from 'react' import type { RecordingDeleteResponse } from '@/app/(campaign)/campanha/(app)/comunicacao/acervo/gravacoes/types' 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 { deleteCampaignJson } from '@/lib/campaignJsonRequest' import { campaignRecordingDeleteHref } from '@/lib/campaignPaths' import { cn } from '@/lib/utils' const DELETE_ERROR_MESSAGE = 'Não foi possível apagar a gravação.' /** * C199 — the delete confirmation of the recording detail. The trigger lives * only here (never on the list cards): an irreversible action stays out of the * scan path, per the approved design. */ export const RecordingDeleteDialog = ({ recordingId, redirectTo, triggerClassName, }: { recordingId: number /** Detail page: the row is gone after the delete, so leave the page. */ redirectTo?: string triggerClassName?: string }) => { const router = useRouter() const [submitting, setSubmitting] = useState(false) const [error, setError] = useState(null) const confirmDelete = async () => { setSubmitting(true) setError(null) try { const { ok, payload } = await deleteCampaignJson( campaignRecordingDeleteHref(recordingId), ) if (!ok || payload.status !== 'success') { setError(payload.status === 'error' ? payload.message : DELETE_ERROR_MESSAGE) return } if (redirectTo) router.push(redirectTo) else router.refresh() } catch { setError(DELETE_ERROR_MESSAGE) } finally { setSubmitting(false) } } return (
{/* The frontend prose base styles every `h2` with a bottom border. */} Apagar esta gravação? O arquivo e toda a transcrição serão removidos. Esta ação não pode ser desfeita.
Cancelar {error ? ( {error} ) : null}
) }