const { Users } = require('../models');

exports.updateUserHostStatus = (userId) => {
  return Users.findByPk(userId).then((user) => {
    const updateData = { is_host: true, has_pending_host_application: false };

    if (!user?.hosting_date) {
      updateData.hosting_date = new Date();
    }

    return Users.update(updateData, { where: { id: userId } });
  });
};
