Fix: Route-Namen (orte/ort-ausfaelle) und /api/users ergänzt

This commit is contained in:
rene 2026-05-21 22:17:03 +02:00
parent 39981c0d17
commit 957c4a9707
4 changed files with 74 additions and 9 deletions

View file

@ -32,8 +32,8 @@
onMount(async () => {
[orte, ausfaelle] = await Promise.all([
api.get<Veranstaltungsort[]>('/veranstaltungsorte', { sort: 'name' }),
api.get<OrtAusfall[]>('/ort_ausfaelle', { sort: 'von' }),
api.get<Veranstaltungsort[]>('/orte', { sort: 'name' }),
api.get<OrtAusfall[]>('/ort-ausfaelle', { sort: 'von' }),
]);
loading = false;
});
@ -55,10 +55,10 @@
try {
const data = { name: fName.trim(), adresse: fAdresse.trim() || null, typ: fTyp, aktiv: fAktiv };
if (editOrtId) {
const u = await api.put<Veranstaltungsort>('/veranstaltungsorte/' + editOrtId, data);
const u = await api.put<Veranstaltungsort>('/orte/' + editOrtId, data);
orte = orte.map(o => o.id === editOrtId ? u : o);
} else {
const n = await api.post<Veranstaltungsort>('/veranstaltungsorte', data);
const n = await api.post<Veranstaltungsort>('/orte', data);
orte = [...orte, n].sort((a, b) => a.name.localeCompare(b.name));
}
showOrtForm = false;
@ -71,7 +71,7 @@
async function ortLoeschen(id: string) {
if (!confirm('Ort wirklich löschen? Alle verknüpften Termine verlieren die Ortzuordnung.')) return;
await api.del('/veranstaltungsorte/' + id);
await api.del('/orte/' + id);
orte = orte.filter(o => o.id !== id);
ausfaelle = ausfaelle.filter(a => a.ort_id !== id);
}
@ -86,7 +86,7 @@
if (aVon > aBis) { ausfallError = 'Bis muss nach Von liegen.'; return; }
ausfallError = ''; ausfallSaving = true;
try {
const n = await api.post<OrtAusfall>('/ort_ausfaelle', {
const n = await api.post<OrtAusfall>('/ort-ausfaelle', {
ort_id: aOrtId, von: aVon, bis: aBis, grund: aGrund.trim() || null,
});
ausfaelle = [...ausfaelle, n].sort((a, b) => a.von.localeCompare(b.von));
@ -99,7 +99,7 @@
}
async function ausfallLoeschen(id: string) {
await api.del('/ort_ausfaelle/' + id);
await api.del('/ort-ausfaelle/' + id);
ausfaelle = ausfaelle.filter(a => a.id !== id);
}

View file

@ -67,8 +67,8 @@
isAdmin()
? api.get<any[]>('/users', { rolle: 'trainer' })
: Promise.resolve([]),
api.get<Veranstaltungsort[]>('/veranstaltungsorte', { sort: 'name', aktiv: 'true' }),
api.get<OrtAusfall[]>('/ort_ausfaelle', { sort: 'von' }),
api.get<Veranstaltungsort[]>('/orte', { sort: 'name', aktiv: 'true' }),
api.get<OrtAusfall[]>('/ort-ausfaelle', { sort: 'von' }),
]);
loading = false;
});