/**
 * ==========================================================
 * Settings Controller
 * ==========================================================
 */

const SettingsService =
require("../services/settings.service");

exports.getSettings = async (req, res) => {

    try {

        const category =
        req.params.category;

        const settings =
        await SettingsService.getCategory(category);

        res.json({

            success: true,

            settings

        });

    }

    catch (error) {

        console.error(error);

        res.status(500).json({

            success: false,

            message: error.message

        });

    }

};

exports.updateSettings = async (req, res) => {

    try {

        const category =
        req.params.category;

        await SettingsService.updateCategory(

            category,

            req.body

        );

        res.json({

            success: true,

            message: "Settings updated successfully."

        });

    }

    catch (error) {

        console.error(error);

        res.status(500).json({

            success: false,

            message: error.message

        });

    }

};