Fragen & Wörter nach Generate it anzeigen und löschen können
- Neue Endpoints: GET /api/object/<id>/questions+words, DELETE /api/question/<id>, DELETE /api/word/<id> - GenerateIt: Wörter-Sidebar mit ×-Chips, Fragen-Sidebar mit Level-Badge und × - Laden beim Objekt-Wechsel und nach Generate it Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -230,3 +230,52 @@ export async function publishQuestions(
|
||||
if (!res.ok) throw new Error(data.error || 'Fehler bei Publish')
|
||||
return data
|
||||
}
|
||||
|
||||
export interface ObjectQuestion {
|
||||
id: string
|
||||
question_de: string
|
||||
answer_de: string
|
||||
level: number
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface ObjectWord {
|
||||
id: string
|
||||
title_de: string
|
||||
level: number
|
||||
status: string
|
||||
}
|
||||
|
||||
export async function getObjectQuestions(objId: string, token: string): Promise<ObjectQuestion[]> {
|
||||
const res = await fetch(`/api/object/${encodeURIComponent(objId)}/questions`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw new Error('Fehler beim Laden der Fragen')
|
||||
return data.data as ObjectQuestion[]
|
||||
}
|
||||
|
||||
export async function getObjectWords(objId: string, token: string): Promise<ObjectWord[]> {
|
||||
const res = await fetch(`/api/object/${encodeURIComponent(objId)}/words`, {
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw new Error('Fehler beim Laden der Wörter')
|
||||
return data.data as ObjectWord[]
|
||||
}
|
||||
|
||||
export async function deleteQuestion(qId: string, token: string): Promise<void> {
|
||||
const res = await fetch(`/api/question/${encodeURIComponent(qId)}`, {
|
||||
method: 'DELETE',
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
if (!res.ok) throw new Error('Fehler beim Löschen der Frage')
|
||||
}
|
||||
|
||||
export async function deleteWord(wId: string, token: string): Promise<void> {
|
||||
const res = await fetch(`/api/word/${encodeURIComponent(wId)}`, {
|
||||
method: 'DELETE',
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
})
|
||||
if (!res.ok) throw new Error('Fehler beim Löschen des Worts')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user