feat: edit and delete pairs in GenerateIt

- Backend: PATCH /api/directus/db-pairs/<id> updates level, statement, question
  (creates question if new, removes if cleared)
- Backend: DELETE /api/directus/db-pairs/<id> removes pair + all junctions,
  questions and statements
- Frontend: inline edit form per pair (level slider, statement, question)
- Frontend: delete button per pair with confirm dialog
- api.ts: updateDbPair, deleteDbPair

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 11:58:57 +02:00
parent 1bbe64db66
commit 8bcb3b9168
3 changed files with 196 additions and 27 deletions

View File

@@ -453,3 +453,24 @@ export async function createDbPair(
if (!res.ok) throw new Error(data.error || 'Fehler beim Erstellen des Pairs')
return data
}
export async function updateDbPair(
pairId: string,
payload: { level?: number; question_de?: string; statement_de?: string },
token: string
): Promise<void> {
const res = await fetch(`/api/directus/db-pairs/${pairId}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
body: JSON.stringify(payload),
})
if (!res.ok) throw new Error('Fehler beim Aktualisieren des Pairs')
}
export async function deleteDbPair(pairId: string, token: string): Promise<void> {
const res = await fetch(`/api/directus/db-pairs/${pairId}`, {
method: 'DELETE',
headers: { Authorization: `Bearer ${token}` },
})
if (!res.ok) throw new Error('Fehler beim Löschen des Pairs')
}