import AccidentService from '../services/accidentService.js';

export const addAccident = async (req, res) => {
    try {
        const { authcode: userToken } = req.headers;
        const { clubId, memberId, diaryDateId, accident } = req.body;
        await AccidentService.createAccident(userToken, clubId, memberId, diaryDateId, accident);
        res.status(201).json({ message: 'Accident added successfully' });
    } catch (error) {
        res.status(500).json({ message: 'Error adding accident', error: error.message });
    }
};

export const getAccidents = async (req, res) => {
    try {
        const { authcode: userToken } = req.headers;
        const { clubId, dateId } = req.params;
        const accidents = await AccidentService.getAccidents(userToken, clubId, dateId);
        res.status(200).json(accidents);
    } catch (error) {
        res.status(500).json({ message: 'Error getting activities', error: error.message });
    }
}