import { useState } from "react"; import { Link } from "react-router-dom"; import { deleteArticle } from "../api"; import { useAdmin } from "./AdminSession"; import Icon from "./Icon"; import Modal from "./Modal"; export default function ArticleAdminActions({ post, onDeleted }) { const { isAdmin, token } = useAdmin(); const [confirming, setConfirming] = useState(false); const [busy, setBusy] = useState(false); const [error, setError] = useState(""); if (!isAdmin) return null; async function remove() { if (busy) return; setBusy(true); setError(""); try { await deleteArticle(post.slug, token); setConfirming(false); onDeleted(post.slug); } catch (requestError) { setError(requestError.message); } finally { setBusy(false); } } return
Edit {confirming && setConfirming(false)} busy={busy}>

“{post.title}” and its uploaded files will be deleted. Files used by another article will be kept. This cannot be undone.

{error &&

{error}

}
}
; }