Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let userID = 0;
- let flexBalance = 0;
- let childSickDaysLeft = 0;
- let userInitials;
- $(document).ready(function () {
- // henter userId
- $.when(getUserIdAPI())
- .then(function (userId) {
- userID = userId
- // henter info om user via userId
- $.when(getUserAPI(userID))
- .then(function (user) {
- insertUserData(user);
- // henter feridata på user via userId
- $.when(getVacationDataAPI(userID))
- .then(function (vacation) {
- $(".vacation-left").text(vacation.RemainingHours + " dage");
- // henter flexdata via initialer
- $.when(getUserFlexDataByInitsAPI(userInitials))
- .then(function (flexData) {
- insertFlexData(flexData);
- // henter barn sygedage via userId
- $.when(getChildSickDaysAPI(userID))
- .then(function (sickDayData) {
- insertChildSickData(sickDayData);
- });
- });
- });
- });
- });
- });
- function insertUserData(user) {
- $(".panel-title").text(user[0].Name);
- $(".name").text(user[0].Name);
- $(".email").append('<a href="' + user[0].Email + '">' + user[0].Email + '</a>');
- let momentStartDate = moment(user[0].StartDate).format('ll');
- userInitials = user[0].Initials;
- $(".start-date").text(momentStartDate);
- }
- function insertFlexData(flexData) {
- flexBalance = flexData[flexData.length - 1].Accumulated;
- $(".flex").text(flexBalance + " timer");
- }
- function insertChildSickData(sickDayData) {
- childSickDaysLeft = sickDayData.HoursRemaining / 7, 40;
- var childSickDaysLeftRounded = Math.round(childSickDaysLeft * 10) / 10;
- $(".sickdays").text(childSickDaysLeftRounded + " dage");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement