const ConstructorService = require('../services/constructor.service');

class ConstructorController {
    async createPack(req, res) {
        const data = req.body;

        if (data) {
            if (req.possibilities.can_add_territory) {
                let result = await ConstructorService.createPack(data);
                
                if (result) {
                    return res.status(200).send(result);
                } else {
                    return res.status(500).send({
                        message: 'Unable create pack.',
                    });
                }
            } else {
                return res
                    .status(403)
                    .send({ message: 'The user does not have enough rights.' });
            }
        } else {
            return res
                .status(401)
                .send({ message: 'Users not found.' });
        }
    }
}

module.exports = new ConstructorController();