const RsvTimetableService = { get_all() { return fetch(get_rest_url('timetable'), { method: 'GET' }) .then(r => { if (!r.ok) throw new Error(`fetch timetables failed: ${r.status}`); return r.json(); }); }, get_availability_for_date(timetable_id, date) { const params = new URLSearchParams({ date: date.toISOString().slice(0, 10), }); return fetch(get_rest_url(`timetable/${timetable_id}/availability?${params}`), { method: 'GET' }) .then(r => { if (!r.ok) throw new Error(`fetch availability failed: ${r.status}`); return r.json(); }); } }