37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
const TERMINE_HANDLER_URL = '/api/js/handler/TermineAjaxHandler';
|
|
|
|
async function termineAjaxRequest(payload) {
|
|
try {
|
|
const response = await fetch(TERMINE_HANDLER_URL, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload)
|
|
});
|
|
const data = await parseJsonResponse(response);
|
|
|
|
if (data.error) {
|
|
throw new Error(data.error);
|
|
}
|
|
return data;
|
|
|
|
} catch (error) {
|
|
console.error('Termine-Ajax-Fehler:', error.message);
|
|
throw error;
|
|
}
|
|
}
|
|
|
|
function getTermine() {
|
|
return termineAjaxRequest({ action: 'get_entries' });
|
|
}
|
|
|
|
function addTermin(datum, zeit, name, notiz, wiederholung, enddatum) {
|
|
return termineAjaxRequest({ action: 'add_termin', datum, zeit, name, notiz, wiederholung, enddatum });
|
|
}
|
|
|
|
function deleteTermin(id) {
|
|
return termineAjaxRequest({ action: 'delete_termin', id });
|
|
}
|
|
|
|
function deleteTerminSerie(serienId) {
|
|
return termineAjaxRequest({ action: 'delete_serie', serienId });
|
|
} |