"use client"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { api, errorText } from "@/lib/api"; /** Deletes a comparison (and its analysis). */ export function ComparisonActions({ id, name }: { id: string; name: string }) { const router = useRouter(); const [confirm, setConfirm] = useState(false); const [busy, setBusy] = useState(false); const [error, setError] = useState(null); async function remove() { setBusy(true); setError(null); try { await api(`/synastries/${id}`, { method: "DELETE" }); router.refresh(); } catch (e) { setError(errorText(e)); setBusy(false); } } return (
{confirm ? ( <> Törlöd a(z) {name} összevetést és az elemzését? ) : ( )} {error && (

{error}

)}
); }