module.exports = (sequelize, DataTypes) => {
  const ClientInterest = sequelize.define(
    "ClientInterest",
    {
      id: {
        type: DataTypes.INTEGER(11),
        allowNull: false,
        primaryKey: true,
        autoIncrement: true,
      },

      type: {
        type: DataTypes.ENUM("cleaning", "kitchen", "warehouse"),
        allowNull: true,
      },

      autonomy: {
        type: DataTypes.INTEGER(11),
        allowNull: true,
        // validate: {
        //   isNumeric: true,
        // },
      },

      weight: {
        type: DataTypes.INTEGER(11),
        allowNull: true,
        // validate: {
        //   isNumeric: true,
        // },
      },

      priceFrom: {
        type: DataTypes.INTEGER(11),
        allowNull: true,
        // validate: {
        //   isNumeric: true,
        // },
      },

      priceTo: {
        type: DataTypes.INTEGER(11),
        allowNull: true,
        // validate: {
        //   isNumeric: true,
        // },
      },

      createdAt: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: sequelize.literal("NOW()"),
      },

      updatedAt: {
        type: DataTypes.DATE,
        allowNull: false,
        defaultValue: sequelize.literal("NOW()"),
      },
    },
    {
      tableName: "sl_clients_interests",
    }
  );

  ClientInterest.associate = () => {
    const { Brand, Feature, StaffMember, Client } = sequelize.models;

    ClientInterest.belongsTo(Brand);

    ClientInterest.belongsTo(Feature);

    ClientInterest.belongsTo(Client, {
      as: "client",
      foreignKey: "clientId",
    });
  };

  return ClientInterest;
};
