"use strict";

appCore.controller("MyTeamSkills", ["$state", "$scope", "$http", "$timeout", "vServices", "$uibModal", "$document",
    function ($state, $scope, $http, $timeout, vServices, $uibModal, $document) {
        $scope.heroes = [];
        $scope.$root.page.title = "List of Heroes Skills";
        $scope.dTable = null;

        $scope.resetPassword = function (hero) {
            vServices.callApi("auth/forgot_password", "POST", {emp_email: hero.emp_email}).then(function (res) {
                if (res) {
                    toastr.success(res, "success", {timeOut: 5000});
                }
            });
        };

        $scope.allActiveEmployees = function () {
           init();
        };

        const init = function () {
            $scope.myHeroes = [];
            if($scope.dTable)$scope.dTable.destroy();
            vServices.callApi("employee/manager_team_skills", "GET", {}).then(function (res) {
                if (res && res.length > 0) {
                    console.log(res);
                    $scope.heroes = res;
                    $scope.$root.callDataTable(".heroList", 500, (t) => {
                        $scope.dTable = t;
                    }, {orientation: "landscape"});
                }
            });
        };
        init();
}])
