const { CocTeam } = require('../../models');
const { formatImage } = require('../../util/formatter');

exports.getCocTeam = async (req, res, next) => {
	try {
		let cocTeam = await CocTeam.findAll({ order: [['order', 'ASC']] });

		cocTeam = cocTeam.map((item) => {
			const coc = item.get({ plain: true });
			coc.image = formatImage(coc.image, 'coc-uploads');
			return coc;
		});

		res.json({
			success: true,
			data: cocTeam,
		});
	} catch (error) {
		next(error);
	}
};
