import MemberTransferConfigService from '../services/memberTransferConfigService.js';

export const getConfig = async (req, res) => {
    try {
        const { id: clubId } = req.params;
        const { authcode: userToken } = req.headers;
        
        const result = await MemberTransferConfigService.getConfig(userToken, clubId);
        res.status(result.status).json(result.response);
    } catch (error) {
        console.error('[getConfig] Error:', error);
        res.status(500).json({
            success: false,
            error: 'Fehler beim Laden der Konfiguration'
        });
    }
};

export const saveConfig = async (req, res) => {
    try {
        const { id: clubId } = req.params;
        const { authcode: userToken } = req.headers;
        const configData = req.body;
        
        const result = await MemberTransferConfigService.saveConfig(userToken, clubId, configData);
        res.status(result.status).json(result.response);
    } catch (error) {
        console.error('[saveConfig] Error:', error);
        res.status(500).json({
            success: false,
            error: 'Fehler beim Speichern der Konfiguration'
        });
    }
};

export const deleteConfig = async (req, res) => {
    try {
        const { id: clubId } = req.params;
        const { authcode: userToken } = req.headers;
        
        const result = await MemberTransferConfigService.deleteConfig(userToken, clubId);
        res.status(result.status).json(result.response);
    } catch (error) {
        console.error('[deleteConfig] Error:', error);
        res.status(500).json({
            success: false,
            error: 'Fehler beim Löschen der Konfiguration'
        });
    }
};

