"use strict";

appCore.controller("AssessmentDashboardCtrl", ["$state", "$scope", "$http", "$timeout", "vServices", "filterFilter", '$uibModal',
    function ($state, $scope, $http, $timeout, vServices, filterFilter, $uibModal) {
        $scope.$root.page.title = "Assessment Dashboard";
        $scope.createButton = {heading: "Add", text: "Submit", icon: "fa-save", today: new Date()};
        $scope.assessmentSchedules = [];
        $scope.filterStatus = 'active';
        const init = () => {
            console.log($state);
            vServices.callApi("/employee/getAssessmentDashboard", "GET", {}).then(ad => {
                // vServices.callApi("employee/getCurrentAssessmentSchedule?emp_id=" + $scope.$root.gUser.id, "GET", {}).then((as) => {
                 vServices.callApi("employee/getCurrentAssessmentScheduleForManagers?emp_id=" + $scope.$root.gUser.id, "GET", {}).then((as) => {
                    as = as.map(o => {
                        o.open = false;
                        o.data = ad.filter(dash => dash.as_ae_id === o.ae_id);
                        return o
                    });
                    $scope.assessmentSchedules = as;
                    $scope.$root.callDataTable("#assessmentDashboard", 200, (t) => {
                    });
                    console.log(as);
                });
            });
        }
        init();
    }
]);