text: import get from 'lodash/get';
  
  
  angular.module('UserAccount').controller('UserAccountUsersDeleteCtrl', class UserAccountUsersDeleteCtrl {
    constructor($scope, UseraccountUsersService, Alerter, $translate) {
      this.$scope = $scope;
      this.usersService = UseraccountUsersService;
      this.alerter = Alerter;
      this.$translate = $translate;
      this.user = $scope.currentActionData;
      this.loader = false;
    }
  
    $onInit() {
      this.$scope.deleteUser = this.deleteUser.bind(this);
    }
  
    deleteUser() {
      this.loader = true;
  
      this.usersService.deleteUser(this.user)
        .then(() => {
          this.alerter.success(this.$translate.instant('user_users_delete_success_message', { login: this.user.login }), 'userUsers');
        })
        .catch((err) => {
          this.alerter.error(`${this.$translate.instant('user_users_delete_error_message')} ${get(err, 'message', err)}`, 'userUsers');
        })
        .finally(() => {
          this.loader = false;
          this.$scope.resetAction();
        });
    }
  });
  