import { RoleEnum } from '@msfa-enums/role.enum';

export interface Role {
  name: string;
  type: RoleEnum;
}

export function mapResponseToRoles(types: RoleEnum[] = []): Role[] {
  return types
    .filter(type => type !== RoleEnum.MSFA_Standard)
    .map(type => {
      switch (type) {
        case 'MSFA_Standard':
          return {
            name: 'Basanvändare',
            type: RoleEnum[type],
          };
        case 'MSFA_ReportAndPlanning':
          return {
            name: 'Rapportering, planering och information om deltagare',
            type: RoleEnum[type],
          };
        case 'MSFA_ReceiveDeltagare':
          return {
            name: 'Ta emot deltagare',
            type: RoleEnum[RoleEnum[type]],
          };
        case 'MSFA_AuthAdmin':
          return {
            name: 'Administrera behörigheter',
            type: RoleEnum[RoleEnum[type]],
          };
        default:
          return;
      }
    });
}
