Add calendar routes to backend and frontend; update routing and UI components for calendar feature

This commit is contained in:
Torsten Schulz (local)
2025-10-17 21:46:32 +02:00
parent a58504a93e
commit 6a0b23e694
7 changed files with 683 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
const CalendarService = require('../services/CalendarService');
/**
* Controller für Kalender
* Verarbeitet HTTP-Requests und delegiert an CalendarService
*/
class CalendarController {
/**
* Holt Kalenderdaten für einen Monat
*/
async getMonth(req, res) {
try {
const userId = req.user?.id || 1;
const year = parseInt(req.query.year) || new Date().getFullYear();
const month = parseInt(req.query.month) || (new Date().getMonth() + 1);
if (isNaN(year) || year < 1900 || year > 2100) {
return res.status(400).json({ message: 'Ungültiges Jahr' });
}
if (isNaN(month) || month < 1 || month > 12) {
return res.status(400).json({ message: 'Ungültiger Monat' });
}
const calendarData = await CalendarService.getCalendarMonth(userId, year, month);
res.json(calendarData);
} catch (error) {
console.error('Fehler beim Abrufen der Kalenderdaten:', error);
res.status(500).json({
message: 'Fehler beim Abrufen der Kalenderdaten',
error: error.message
});
}
}
}
module.exports = new CalendarController();