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 theme_profiles = sequelize.define(
    'theme_profiles',
    {
      id: {
        type: DataTypes.UUID,
        defaultValue: DataTypes.UUIDV4,
        primaryKey: true,
      },

mode: {
        type: DataTypes.ENUM,
      
      

        values: [

"auto_time",


"manual",


"holiday"

        ],

      },

theme_name: {
        type: DataTypes.TEXT,
      
      

      },

primary_color_hex: {
        type: DataTypes.TEXT,
      
      

      },

accent_color_hex: {
        type: DataTypes.TEXT,
      
      

      },

neon_glow_color_hex: {
        type: DataTypes.TEXT,
      
      

      },

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

      },

rgb_cycle_speed: {
        type: DataTypes.INTEGER,
      
      

      },

holiday_palette: {
        type: DataTypes.ENUM,
      
      

        values: [

"none",


"new_year",


"valentines",


"st_patricks",


"easter",


"ramadan",


"eid",


"pride",


"halloween",


"thanksgiving",


"hanukkah",


"christmas",


"lunar_new_year",


"diwali",


"other"

        ],

      },

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

      },

adult_primary_color_hex: {
        type: DataTypes.TEXT,
      
      

      },

adult_accent_color_hex: {
        type: DataTypes.TEXT,
      
      

      },

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

  theme_profiles.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.theme_profiles.belongsTo(db.users, {
      as: 'owner_user',
      foreignKey: {
        name: 'owner_userId',
      },
      constraints: false,
    });

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




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

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



  return theme_profiles;
};


