const Sequelize = require("sequelize");
const sequelizeConnect = require("../connection/db");
const SellerModules = require("./SellerModules");

const SellerGroupPermissions = sequelizeConnect.define(
  "seller_group_permissions",
  {
    id: {
      type: Sequelize.BIGINT,
      primaryKey: true,
      allowNull: false,
      autoIncrement: true,
    },
    seller_module_id: {
      type: Sequelize.BIGINT,
      allowNull: false,
    },
    seller_group_id: {
      type: Sequelize.BIGINT,
      allowNull: false,
    },
    view_permission: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: true,
    },
    add_permission: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: true,
    },
    edit_permission: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: true,
    },
    delete_permission: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: true,
    },
    status: {
      type: Sequelize.BOOLEAN,
      allowNull: false,
      defaultValue: true,
    },
  },
  {
    tableName: "seller_group_permissions",
    timestamps: false,
  }
);

SellerGroupPermissions.belongsTo(SellerModules, {
  foreignKey: "seller_module_id",
  as: "module"
})

module.exports = SellerGroupPermissions;
