diff --git a/src/controllers/products/productController.js b/src/controllers/products/productController.js index 2f00c50..29ce3e7 100644 --- a/src/controllers/products/productController.js +++ b/src/controllers/products/productController.js @@ -146,7 +146,6 @@ cron.schedule('30 17 * * *', async () => { } } }); - console.log(`=========${todayWithTimeZone}=========`); for (const product of expiredProducts) { product.status = 'UNAVAILABLE'; await product.save(); diff --git a/src/controllers/shoppingCartController/addToCartController.js b/src/controllers/shoppingCartController/addToCartController.js index 3882181..c973347 100644 --- a/src/controllers/shoppingCartController/addToCartController.js +++ b/src/controllers/shoppingCartController/addToCartController.js @@ -135,14 +135,6 @@ export const viewCart = asyncWrapper(async (req, res) => { message: req.t('cart_already_empty'), }); } - console.log(`===================> ${cart}==================`); - - // console.log(`===================> ${cartProduct}==================`); - // cartProduct.forEach((cart) => { - // const product = db.ProductAttribute.findOne({ - // where: {} - // }) - // }) res.status(200).json({ status: req.t('success'), @@ -168,7 +160,7 @@ export const pay = asyncWrapper(async (req, res) => { exp_year: exp_year, cvc: cvcNumber, }; - console.log(card); + const paymentMethod = await stripe.paymentMethods.create({ type: 'card', card, diff --git a/src/controllers/shoppingCartController/updateCartController.js b/src/controllers/shoppingCartController/updateCartController.js index d8c4205..11bf63d 100644 --- a/src/controllers/shoppingCartController/updateCartController.js +++ b/src/controllers/shoppingCartController/updateCartController.js @@ -4,7 +4,6 @@ import { getCarts, CalculateTotalPrice } from '../../utils/getCartsHandler'; export const updateCart = asyncWrapper(async (req, res) => { const { id, quantity } = req.body; - // console.log('Hello id',id); const buyerId = req.user.id; const cart = await getCarts(buyerId) if (!cart) @@ -35,7 +34,6 @@ export const updateCart = asyncWrapper(async (req, res) => { }); const newCart = await getCarts(buyerId); const totalPrice = CalculateTotalPrice(newCart); - console.log('Hello total', totalPrice); res.status(201).json({ status: req.t('success'), message: req.t('cart_item_updated'), diff --git a/src/controllers/users/adminControllers.js b/src/controllers/users/adminControllers.js index 1b90585..eef0571 100644 --- a/src/controllers/users/adminControllers.js +++ b/src/controllers/users/adminControllers.js @@ -7,7 +7,7 @@ export const createAdmin = asyncWrapper(async (req, res) => { req.body; const hashedPassword = await hashPassword(password); - let newRole = await db.role.create({ + let newRole = await db.role.findOne({ name: 'admin', }); while(!newRole){ @@ -38,7 +38,7 @@ export const getAllUsers =asyncWrapper(async (req, res) => { attributes: { exclude: ['password', 'roleId'] }, include: { model: db.role, - attributes: ['name'], + attributes: ['name', 'id'], include: { model: db.permission, attributes: { exclude: ['id'] }, @@ -60,13 +60,12 @@ export const deleteUsers =asyncWrapper(async (req, res) => { }); }); export const getSingleUser =asyncWrapper(async (req, res) => { - console.log(req.params.id); const singleUser = await db.user.findAll({ where: { id: req.params.id }, attributes: { exclude: ['password', 'roleId'] }, include: { model: db.role, - attributes: ['name'], + attributes: ['name', 'id'], include: { model: db.permission, attributes: { exclude: ['id'] }, diff --git a/src/database/models/role.js b/src/database/models/role.js index e0171e6..b46225b 100644 --- a/src/database/models/role.js +++ b/src/database/models/role.js @@ -9,15 +9,15 @@ module.exports = (sequelize, DataTypes) => { */ static associate(models) { // define association here - role.hasMany(models.user, { foreignKey: 'roleId'}); - role.belongsToMany(models.permission, { - through: models.rolePermission, - }); + role.hasMany(models.user, { foreignKey: 'roleId' }); + role.belongsToMany(models.permission, { + through: models.rolePermission, + }); } } role.init( { - name: { allowNull: false, type: DataTypes.STRING }, + name: { allowNull: false, type: DataTypes.STRING, unique: true }, }, { sequelize,