1
0

Create mobile calender service

This commit is contained in:
2025-07-18 11:49:28 +02:00
parent 53e2b15351
commit 3608750616
16 changed files with 6749 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import requestUtil from '../utils/RequestUtil';
class CalendarService {
constructor() {
this.endpoint = '/api/calendar';
}
// Get all calendar users
async getUsers() {
return requestUtil.get(`${this.endpoint}/users`);
}
// Get calendar events for a specific month
async getEventsForMonth(year, month, user = null, type = 'family') {
let url = `${this.endpoint}/events/${year}/${month}?type=${type}`;
if (user && type === 'individual') {
url += `&user=${encodeURIComponent(user)}`;
}
return requestUtil.get(url);
}
// Create a new calendar event
async createEvent(event) {
return requestUtil.post(`${this.endpoint}/events`, event);
}
// Update a calendar event
async updateEvent(eventId, event) {
return requestUtil.put(`${this.endpoint}/events/${eventId}`, event);
}
// Delete a calendar event
async deleteEvent(eventId, user) {
return requestUtil.delete(`${this.endpoint}/events/${eventId}`, { user });
}
// Health check
async healthCheck() {
return requestUtil.get('/api/health');
}
}
// Create and export a singleton instance
const calendarService = new CalendarService();
export default calendarService;