"use client"; import Link from "next/link"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { api, errorText } from "@/lib/api"; /** Correct (while allowed) or delete a person. */ export function PersonActions({ id, name, editable }: { id: string; name: string; editable: boolean }) { 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(`/charts/${id}`, { method: "DELETE" }); router.refresh(); } catch (e) { setError(errorText(e)); setBusy(false); } } return (
{confirm ? ( <> Törlöd {name} képletét és elemzéseit? A hely nem szabadul fel. ) : ( <> {editable && ( Adatok javítása )} )} {error && (

{error}

)}
); }