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

label: {
        type: DataTypes.TEXT,
      
      

      },

cta_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"request_samples",


"get_a_quote",


"contact_us",


"subscribe",


"partner_with_us"

        ],

      },

url: {
        type: DataTypes.TEXT,
      
      

      },

style_variant: {
        type: DataTypes.ENUM,
      
      

        values: [

"primary",


"secondary",


"outline",


"link"

        ],

      },

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

      },

sort_order: {
        type: DataTypes.INTEGER,
      
      

      },

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

  cta_buttons.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.cta_buttons.belongsTo(db.pages, {
      as: 'page',
      foreignKey: {
        name: 'pageId',
      },
      constraints: false,
    });




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

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



  return cta_buttons;
};


