export class Employee {
  constructor(
    public id: number,
    public firstName: string,
    public lastName: string,
    public permissions: EmployeePermission[],
    public group?: EmployeeGroup,
    public lastLoginTime?: Date
  ) {
  }
}

export class EmployeeGroup {
  constructor(
    public id: number,
    public name: string,
    public permissions: EmployeePermission[],
    public employeeCount: number
  ) {
  }
}

export enum EmployeePermission {
  VIEW_MATERIAL = 'VIEW_MATERIAL',
  VIEW_MATERIAL_TYPE = 'VIEW_MATERIAL_TYPE',
  VIEW_COMPANY = 'VIEW_COMPANY',
  VIEW_RECIPE = 'VIEW_RECIPE',
  VIEW = 'VIEW',
  VIEW_EMPLOYEE = 'VIEW_EMPLOYEE',
  VIEW_EMPLOYEE_GROUP = 'VIEW_EMPLOYEE_GROUP',

  EDIT_MATERIAL = 'EDIT_MATERIAL',
  EDIT_MATERIAL_TYPE = 'EDIT_MATERIAL_TYPE',
  EDIT_COMPANY = 'EDIT_COMPANY',
  EDIT_RECIPE = 'EDIT_RECIPE',
  EDIT = 'EDIT',
  EDIT_EMPLOYEE = 'EDIT_EMPLOYEE',
  EDIT_EMPLOYEE_PASSWORD = 'EDIT_EMPLOYEE_PASSWORD',
  EDIT_EMPLOYEE_GROUP = 'EDIT_EMPLOYEE_GROUP',

  REMOVE_MATERIAL = 'REMOVE_MATERIAL',
  REMOVE_MATERIAL_TYPE = 'REMOVE_MATERIAL_TYPE',
  REMOVE_COMPANY = 'REMOVE_COMPANY',
  REMOVE_RECIPE = 'REMOVE_RECIPE',
  REMOVE = 'REMOVE',
  REMOVE_EMPLOYEE = 'REMOVE_EMPLOYEE',
  REMOVE_EMPLOYEE_GROUP = 'REMOVE_EMPLOYEE_GROUP',

  SET_BROWSER_DEFAULT_GROUP = 'SET_BROWSER_DEFAULT_GROUP',
  ADMIN = 'ADMIN'
}

export const mapped_permissions = {
  view: [
    {permission: EmployeePermission.VIEW_MATERIAL, description: 'Voir les produits', impliedPermissions: []},
    {
      permission: EmployeePermission.VIEW_MATERIAL_TYPE,
      description: 'Voir les types de produit',
      impliedPermissions: []
    },
    {permission: EmployeePermission.VIEW_COMPANY, description: 'Voir les bannières', impliedPermissions: []},
    {permission: EmployeePermission.VIEW_RECIPE, description: 'Voir les couleurs', impliedPermissions: []},
    {
      permission: EmployeePermission.VIEW,
      description: 'Voir',
      impliedPermissions: [EmployeePermission.VIEW_MATERIAL, EmployeePermission.VIEW_MATERIAL_TYPE, EmployeePermission.VIEW_COMPANY, EmployeePermission.VIEW_RECIPE]
    },
    {permission: EmployeePermission.VIEW_EMPLOYEE, description: 'Voir les employés', impliedPermissions: []},
    {permission: EmployeePermission.VIEW_EMPLOYEE_GROUP, description: 'Voir les groupes', impliedPermissions: []},
  ],
  edit: [
    {
      permission: EmployeePermission.EDIT_MATERIAL,
      description: 'Modifier les produits',
      impliedPermissions: [EmployeePermission.VIEW_MATERIAL_TYPE]
    },
    {
      permission: EmployeePermission.EDIT_MATERIAL_TYPE,
      description: 'Modifier les types de produit',
      impliedPermissions: [EmployeePermission.VIEW_MATERIAL_TYPE]
    },
    {
      permission: EmployeePermission.EDIT_COMPANY,
      description: 'Modifier les bannières',
      impliedPermissions: [EmployeePermission.VIEW_COMPANY]
    },
    {
      permission: EmployeePermission.EDIT_RECIPE,
      description: 'Modifier les couleurs',
      impliedPermissions: [EmployeePermission.VIEW_RECIPE]
    },
    {
      permission: EmployeePermission.EDIT,
      description: 'Modifier',
      impliedPermissions: [EmployeePermission.EDIT_MATERIAL, EmployeePermission.EDIT_MATERIAL_TYPE, EmployeePermission.EDIT_COMPANY, EmployeePermission.EDIT_RECIPE, EmployeePermission.VIEW]
    },
    {
      permission: EmployeePermission.EDIT_EMPLOYEE,
      description: 'Modifier les employés',
      impliedPermissions: [EmployeePermission.VIEW_EMPLOYEE]
    },
    {
      permission: EmployeePermission.EDIT_EMPLOYEE_PASSWORD,
      description: 'Modifier le mot de passe des employés',
      impliedPermissions: [EmployeePermission.EDIT_EMPLOYEE]
    },
    {
      permission: EmployeePermission.EDIT_EMPLOYEE_GROUP,
      description: 'Modifier les groupes',
      impliedPermissions: [EmployeePermission.VIEW_EMPLOYEE_GROUP]
    },
  ],
  remove: [
    {
      permission: EmployeePermission.REMOVE_MATERIAL,
      description: 'Supprimer des produits',
      impliedPermissions: [EmployeePermission.EDIT_MATERIAL]
    },
    {
      permission: EmployeePermission.REMOVE_MATERIAL_TYPE,
      description: 'Supprimer des types de produit',
      impliedPermissions: [EmployeePermission.EDIT_MATERIAL_TYPE]
    },
    {
      permission: EmployeePermission.REMOVE_COMPANY,
      description: 'Supprimer des bannières',
      impliedPermissions: [EmployeePermission.EDIT_COMPANY]
    },
    {
      permission: EmployeePermission.REMOVE_RECIPE,
      description: 'Supprimer des couleurs',
      impliedPermissions: [EmployeePermission.EDIT_RECIPE]
    },
    {
      permission: EmployeePermission.REMOVE,
      description: 'Supprimer',
      impliedPermissions: [EmployeePermission.REMOVE_MATERIAL, EmployeePermission.REMOVE_MATERIAL_TYPE, EmployeePermission.REMOVE_COMPANY, EmployeePermission.REMOVE_RECIPE, EmployeePermission.EDIT]
    },
    {
      permission: EmployeePermission.REMOVE_EMPLOYEE,
      description: 'Supprimer des employés',
      impliedPermissions: [EmployeePermission.EDIT_EMPLOYEE]
    },
    {
      permission: EmployeePermission.REMOVE_EMPLOYEE_GROUP,
      description: 'Supprimer des groupes',
      impliedPermissions: [EmployeePermission.EDIT_EMPLOYEE_GROUP]
    },
  ],
  other: [
    {
      permission: EmployeePermission.SET_BROWSER_DEFAULT_GROUP,
      description: 'Définir le groupe par défaut',
      impliedPermissions: [EmployeePermission.VIEW_EMPLOYEE_GROUP]
    },
    {
      permission: EmployeePermission.ADMIN,
      description: 'Administrateur',
      impliedPermissions: [EmployeePermission.REMOVE, EmployeePermission.SET_BROWSER_DEFAULT_GROUP, EmployeePermission.REMOVE_EMPLOYEE, EmployeePermission.EDIT_EMPLOYEE_PASSWORD, EmployeePermission.REMOVE_EMPLOYEE_GROUP]
    }
  ]
}
