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

feedback_type: {
        type: DataTypes.ENUM,
      
      

        values: [

"nps",


"csat",


"bug",


"feature_request",


"freeform"

        ],

      },

score: {
        type: DataTypes.INTEGER,
      
      

      },

comment: {
        type: DataTypes.TEXT,
      
      

      },

source_surface: {
        type: DataTypes.ENUM,
      
      

        values: [

"landing",


"onboarding",


"profile",


"coach",


"offer",


"checkout",


"course",


"lesson",


"trophy_case",


"other"

        ],

      },

submitted_at: {
        type: DataTypes.DATE,
      
      

      },

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

      },

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

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




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

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



  return feedback_entries;
};


