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_EMPLOYEE = 'VIEW_EMPLOYEE',
  VIEW_EMPLOYEE_GROUP = 'VIEW_EMPLOYEE_GROUP',
  VIEW = 'VIEW',

  EDIT_EMPLOYEE = 'EDIT_EMPLOYEE',
  EDIT_EMPLOYEE_PASSWORD = 'EDIT_EMPLOYEE_PASSWORD',
  EDIT_EMPLOYEE_GROUP = 'EDIT_EMPLOYEE_GROUP',
  EDIT = 'EDIT',

  REMOVE_EMPLOYEE = 'REMOVE_EMPLOYEE',
  REMOVE_EMPLOYEE_GROUP = 'REMOVE_EMPLOYEE_GROUP',
  REMOVE = 'REMOVE',

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

export const mapped_permissions = {
  view: [
    {permission: EmployeePermission.VIEW_EMPLOYEE, description: 'Voir les employés', impliedPermissions: []},
    {permission: EmployeePermission.VIEW_EMPLOYEE_GROUP, description: 'Voir les groupes', impliedPermissions: []},
    {permission: EmployeePermission.VIEW, description: 'Voir', impliedPermissions: []},
  ],
  edit: [
    {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]},
    {permission: EmployeePermission.EDIT, description: 'Modifier', impliedPermissions: [EmployeePermission.VIEW]},
  ],
  remove: [
    {permission: EmployeePermission.REMOVE_EMPLOYEE, description: 'Supprimer les employés', impliedPermissions: [EmployeePermission.EDIT_EMPLOYEE]},
    {permission: EmployeePermission.REMOVE_EMPLOYEE_GROUP, description: 'Supprimer les groupes', impliedPermissions: [EmployeePermission.EDIT_EMPLOYEE_GROUP]},
    {permission: EmployeePermission.REMOVE, description: 'Supprimer', impliedPermissions: [EmployeePermission.EDIT]},
  ],
  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]}
  ]
}
