Add widget functionality for birthdays, upcoming events, and mini calendar: Implement new API endpoints in calendarController and calendarService to retrieve upcoming birthdays and events, as well as mini calendar data. Update calendarRouter to include widget routes and enhance DashboardWidget to dynamically render new widget components. This update improves user experience by providing quick access to important calendar information.
This commit is contained in:
@@ -140,5 +140,64 @@ export default {
|
||||
console.error('Calendar getFriendsBirthdays:', error);
|
||||
res.status(500).json({ error: error.message || 'Internal server error' });
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /api/calendar/widget/birthdays
|
||||
* Get upcoming birthdays for widget display
|
||||
*/
|
||||
async getWidgetBirthdays(req, res) {
|
||||
const hashedUserId = getHashedUserId(req);
|
||||
if (!hashedUserId) {
|
||||
return res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
try {
|
||||
const limit = parseInt(req.query.limit) || 10;
|
||||
const birthdays = await calendarService.getUpcomingBirthdays(hashedUserId, limit);
|
||||
res.json(birthdays);
|
||||
} catch (error) {
|
||||
console.error('Calendar getWidgetBirthdays:', error);
|
||||
res.status(500).json({ error: error.message || 'Internal server error' });
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /api/calendar/widget/upcoming
|
||||
* Get upcoming events for widget display
|
||||
*/
|
||||
async getWidgetUpcoming(req, res) {
|
||||
const hashedUserId = getHashedUserId(req);
|
||||
if (!hashedUserId) {
|
||||
return res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
try {
|
||||
const limit = parseInt(req.query.limit) || 10;
|
||||
const events = await calendarService.getUpcomingEvents(hashedUserId, limit);
|
||||
res.json(events);
|
||||
} catch (error) {
|
||||
console.error('Calendar getWidgetUpcoming:', error);
|
||||
res.status(500).json({ error: error.message || 'Internal server error' });
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* GET /api/calendar/widget/mini
|
||||
* Get mini calendar data for widget display
|
||||
*/
|
||||
async getWidgetMiniCalendar(req, res) {
|
||||
const hashedUserId = getHashedUserId(req);
|
||||
if (!hashedUserId) {
|
||||
return res.status(401).json({ error: 'Unauthorized' });
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await calendarService.getMiniCalendarData(hashedUserId);
|
||||
res.json(data);
|
||||
} catch (error) {
|
||||
console.error('Calendar getWidgetMiniCalendar:', error);
|
||||
res.status(500).json({ error: error.message || 'Internal server error' });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user