import calendarHolidayService from '../services/calendarHolidayService.js';

export const getClubCalendarDays = async (req, res) => {
  try {
    const { authcode: token } = req.headers;
    const { clubId } = req.params;
    const { year } = req.query;
    const result = await calendarHolidayService.getClubCalendarDays(token, clubId, year);
    res.status(200).json(result);
  } catch (error) {
    if (error.message === 'clubnotfound') {
      res.status(404).json({ error: 'clubnotfound' });
    } else if (error.message === 'noaccess') {
      res.status(403).json({ error: 'noaccess' });
    } else {
      console.error('[getClubCalendarDays] - error:', error);
      res.status(502).json({ error: 'calendarproviderfailed' });
    }
  }
};
