const config = require('../../config');
const providers = config.providers;
const crypto = require('crypto');
const bcrypt = require('bcrypt');
const moment = require('moment');

module.exports = function(sequelize, DataTypes) {
  const user_settings = sequelize.define(
    'user_settings',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

time_zone: {
        type: DataTypes.TEXT,
      
      

      },

locale: {
        type: DataTypes.TEXT,
      
      

      },

theme: {
        type: DataTypes.ENUM,
      
      

        values: [

"light",


"dark",


"system"

        ],

      },

default_entry_mode: {
        type: DataTypes.ENUM,
      
      

        values: [

"chat",


"voice"

        ],

      },

voice_mode_enabled: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

preferred_voice: {
        type: DataTypes.TEXT,
      
      

      },

speech_rate: {
        type: DataTypes.DECIMAL,
      
      

      },

speech_pitch: {
        type: DataTypes.DECIMAL,
      
      

      },

safe_confirmations_enabled: {
        type: DataTypes.BOOLEAN,
      
        allowNull: false,
        defaultValue: false,
      
      

      },

auto_archive_days: {
        type: DataTypes.INTEGER,
      
      

      },

      importHash: {
        type: DataTypes.STRING(255),
        allowNull: true,
        unique: true,
      },
    },
    {
      timestamps: true,
      paranoid: true,
      freezeTableName: true,
    },
  );

  user_settings.associate = (db) => {


/// loop through entities and it's fields, and if ref === current e[name] and create relation has many on parent entity































//end loop



    db.user_settings.belongsTo(db.organizations, {
      as: 'organizations',
      foreignKey: {
        name: 'organizationsId',
      },
      constraints: false,
    });




    db.user_settings.belongsTo(db.users, {
      as: 'createdBy',
    });

    db.user_settings.belongsTo(db.users, {
      as: 'updatedBy',
    });
  };



  return user_settings;
};


