diff --git a/src/pages/ContentCreation.jsx b/src/pages/ContentCreation.jsx index b1621fd..31d8297 100644 --- a/src/pages/ContentCreation.jsx +++ b/src/pages/ContentCreation.jsx @@ -1,6 +1,6 @@ import { useEffect, useState, useRef, useCallback, useMemo } from 'react'; import Layout from '../components/Layout'; -import { apiFetch, apiPost, apiPatch, apiLink, apiUnlink, getUserLang } from '../lib/api'; +import { apiFetch, apiPost, apiPatch, apiLink, apiUnlink, apiDelete, getUserLang } from '../lib/api'; import { STATUS_COLORS } from '../lib/tables'; // ─── Word / placeholder helpers ─────────────────────────────────────────────── @@ -425,7 +425,7 @@ function PairForm({ objectId, allObjects, onPairSaved }) { // ─── EditPairForm ───────────────────────────────────────────────────────────── -function EditPairForm({ pair, allObjects, onSaved, onCancel }) { +function EditPairForm({ pair, allObjects, onSaved, onCancel, onDeleted }) { const lang = getUserLang(); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); @@ -441,9 +441,20 @@ function EditPairForm({ pair, allObjects, onSaved, onCancel }) { const [selection, setSelection] = useState(''); const [wordInput, setWordInput] = useState(''); const [creatingWord, setCreatingWord] = useState(false); + const [confirmDelete, setConfirmDelete] = useState(false); + const [deleting, setDeleting] = useState(false); useEffect(() => { setWordInput(selection); }, [selection]); + async function handleDelete() { + setDeleting(true); + try { + await apiDelete('/pairs', pair.id); + onDeleted(pair.id); + } catch (e) { alert('Fehler beim Löschen: ' + e.message); } + finally { setDeleting(false); } + } + useEffect(() => { async function load() { try { @@ -675,11 +686,30 @@ function EditPairForm({ pair, allObjects, onSaved, onCancel }) { )} -