import { useState } from "react"; import Icon from "./Icon"; const BESTAETIGUNG = "LÖSCHEN"; /** * Eine unwiderrufliche Aktion im Gefahrenbereich. * * Absichtlich umständlich: Der Text nennt vorher, was genau verschwindet, und * ausgelöst wird erst, wenn das Wort getippt wurde. Ein Fehlklick soll hier * nichts anrichten können. */ export default function DangerAction({ title, description, impact, buttonLabel, onRun }) { const [wort, setWort] = useState(""); const [busy, setBusy] = useState(false); const bereit = wort.trim().toUpperCase() === BESTAETIGUNG; async function run() { if (!bereit) return; setBusy(true); try { await onRun(); setWort(""); } finally { setBusy(false); } } return (
{description}
{impact}