$(document).click(function(){ setTimeout( function() { if($('#nav-dashboard').hasClass('show')){ $('.service-request-list').show(); $('.vouchers').show(); } else{ $('.service-request-list').hide(); $('.vouchers').hide(); } },500); }); $(document).ready(function() { if (document.referrer.indexOf("/restaurants/") > -1){ $('#nav-dashboard-tab').removeClass("active"); $('#nav-offers-tab').addClass("active"); $('#nav-dashboard').removeClass("active"); $('#nav-dashboard').removeClass("show"); $('#nav-offers').addClass("active"); $('#nav-offers').addClass("show"); $('.service-request-list').hide(); $('.vouchers').hide(); } }) $(window).load(function() { var userDetails = getUserData(); var profile_name = ""; if(userDetails && userDetails.nameDetails && userDetails.nameDetails.salutation != null){ profile_name = userDetails.nameDetails.salutation +" " +userDetails.nameDetails.firstName +" "+ userDetails.nameDetails.lastName; } else if(userDetails && userDetails.nameDetails){ profile_name = userDetails.nameDetails.firstName +" " + userDetails.nameDetails.lastName; } $('.profile-name').html(profile_name); if($('.profile-membership-id .membership-no')[0]){ $('.profile-membership-id .membership-no')[0].remove(); } if(userDetails && userDetails.brandData && userDetails.brandData.ticNumber && userDetails.brandData.ticNumber[0]){ var membership_id = ' ' + userDetails.brandData.ticNumber[0] + ''; $('.profile-membership-id').append( membership_id ); }else if(userDetails && userDetails.tcpNumber){ userDetails.brandData.ticNumber = []; userDetails.brandData.ticNumber[0] = userDetails.tcpNumber; var membership_id = ' ' + userDetails.tcpNumber + ''; $('.profile-membership-id').append( membership_id ); }else{ $('.profile-membership-id').hide(); } /*hide the cta of banner carousal first banner for user specific*/ $($('#bannerCarousel').find(".carousel-item .mr-visit-hotel")[0]).hide() if (document.referrer.indexOf("/restaurants/") > -1){ $('#nav-dashboard-tab').removeClass("active"); $('#nav-offers-tab').addClass("active"); $('#nav-dashboard').removeClass("active"); $('#nav-dashboard').removeClass("show"); $('#nav-offers').addClass("active"); $('#nav-offers').addClass("show"); $('.service-request-list').hide(); $('.vouchers').hide(); } if($('#nav-dashboard').hasClass('show')){ $('.service-request-list').show(); $('.vouchers').show(); } else{ $('.service-request-list').hide(); $('.vouchers').hide(); } /*Membership benefits hide-show based on tab - show only current tier and next tier benefits*/ if($('#nav-offers-tab').hasClass('show')){ $('.tic-membership-tiers').show(); $('.tic-membership-tiers').prev().show() }else{ $('.tic-membership-tiers').hide(); $('.tic-membership-tiers').prev().hide(); } /*Tier specific show hide- only show current and current+1 tier*/ var currentSlab = data.userDetails.loyaltyInfo[0].currentSlab; if(currentSlab == "Copper" || currentSlab == "Copper*"){ $('.tier-platinum-card-color').remove(); $('.tier-gold-card-color').remove(); }else if(currentSlab == "Silver"){ $('.tier-platinum-card-color').remove(); $('.tier-copper-card-color').remove(); }else if(currentSlab == "Gold"){ $('.tier-silver-card-color').remove(); $('.tier-copper-card-color').remove(); }else if(currentSlab == "Platinum"){ $('.tier-silver-card-color').remove(); $('.tier-copper-card-color').remove(); $('.tier-gold-card-color').remove(); } $('.membership-tires-inner-container').css('justify-content', 'normal'); getCustomerLoyaltyDetails(); // getOffersFromVault(); }); setTimeout(function(){ $('#nav-offers-tab').click(function(){ setTimeout(function(){ $('.tic-membership-tiers').show(); $('.tic-membership-tiers').prev().show(); var parent = document.getElementsByClassName('membership-tires-inner-container')[0]; var arr = Array.from($('.membership-tires-inner-container').find("div[class*='tier']")); arr.reverse(); parent.append(...arr); $($('.membership-tires-inner-container .membership-tires-individual-card-header')[1]).prepend ('

Current Tier

');; if($('.membership-tires-individual-card-header')[2]){ $($('.membership-tires-inner-container .membership-tires-individual-card-header')[2]).prepend ('

Next Tier

'); } $('.individual-card-header-image').css('top','50px'); $('.membership-tires-individual-card-body-container').css('margin-top','20px'); },1500); }); $('.nav-tabs').click(function(e){ if($(e.target).find('a').attr('id') != 'nav-offers-tab'){ $('.tic-membership-tiers').hide(); $('.tic-membership-tiers').prev().hide(); } }); }, 1500); function getCustomerLoyaltyDetails() { var accesstkn = localStorage.getItem("access_token"); var clientID = document.querySelector("meta[name='tdl-sso-client_id']").getAttribute("content"); if(localStorage.hasOwnProperty("user")){ var customerHash = JSON.parse(localStorage.getItem("user")).customerHash; } else{ var customerHash = JSON.parse(localStorage.getItem("userData")).customerHash; } var userData = getUserData();var loyaltyPoints; if(userData && userData.loyaltyInfo && userData.loyaltyInfo[0]){ loyaltyPoints = userData.loyaltyInfo[0].loyaltyPoints; } $.ajax({ method : 'POST', url : '/bin/getTdLoyalty', data : { authToken : accesstkn }, dataType : "json", }).done(function(data) { data = JSON.parse(data); if(data.loyaltyProgramDetails != undefined){ if(data.loyaltyProgramDetails.length > 0){ for(var i=0;i < data.loyaltyProgramDetails.length;i++){ if(data.loyaltyProgramDetails[i].programTitle == "Tata IHCL Loyalty" || data.loyaltyProgramDetails[i].programTitle == "Taj" || data.loyaltyProgramDetails[i].programTitle == "IHCL" || data.loyaltyProgramDetails[i].programId == '1000014'){ var membership_expiry = data.loyaltyProgramDetails[i].slabExpiryDate.split("T")[0].split("-"); var modified_expiry = membership_expiry[2] + "-" + membership_expiry[1] + "-" + membership_expiry[0] ; $('.balance-points-num').html(data.loyaltyProgramDetails[i].loyaltyPoints); if(data.loyaltyProgramDetails[i].currentSlab != null && data.loyaltyProgramDetails[i].currentSlab != "") $('.current-tier-name').html(data.loyaltyProgramDetails[i].currentSlab); else $('.current-tier-name').parent().hide(); if(data.loyaltyProgramDetails[i].nextSlab != null && data.loyaltyProgramDetails[i].nextSlab != "") $('.next-tier-name').html(data.loyaltyProgramDetails[i].nextSlab); else $('.next-tier-name').parent().hide(); $('.membership-date').html(modified_expiry); /*This is brand loyalty points - later overwritten by group loyalty points as per fetch customer response*/ loyaltyPoints = loyaltyPoints ? loyaltyPoints: data.loyaltyProgramDetails[i].loyaltyPoints; $('.points-details-total').html(loyaltyPoints); $('.balance-points-num').html(loyaltyPoints); $('.points-details-redeemed').html(data.loyaltyProgramDetails[i].redeemed); $('.points-details-expired').html(data.loyaltyProgramDetails[i].expired); } } } } }) .fail(function(error) { console.log("error in fetchdetails api",error); }); } function getOffersFromVault() { var accesstkn = localStorage.getItem("access_token"); var clientID = document.querySelector("meta[name='tdl-sso-client_id']").getAttribute("content"); if(localStorage.hasOwnProperty("user")){ var customerHash = JSON.parse(localStorage.getItem("user")).customerHash; } else{ var customerHash = JSON.parse(localStorage.getItem("userData")).customerHash; } var key = "xvIvkuxKczCf8sapHZv5ia9qzPEB9iPRvtLr4iJn4SzmMjfuWgVvSsXvyw=="; var package = "gzHdpwynOXLUYPfHNLnZKwjYy7ZZGHG4vEdmT/O0Y="; var source = "TBPTNR"; var req_data = { 'getOffersFromVaultRequest':{ 'customerHash':customerHash, 'programId': 'b098cfab-0bfd-4c0e-9a7d-4bee045ee809', } }; $.ajax({ method : 'POST', url : '/bin/getOfferTd', data : { req_data : JSON.stringify(req_data), authToken : accesstkn }, dataType : "json", }).done(function(data) { data = JSON.parse(data); if(data.getOffersFromVaultResponse != undefined){ if(data.getOffersFromVaultResponse.vaultOfferDetails.length > 0){ for(var i=0;i< data.getOffersFromVaultResponse.vaultOfferDetails.length;i++){ var date = new Date(); date.setDate(date.getDate() + Number(data.getOffersFromVaultResponse.vaultOfferDetails[i].offerExpiringIn.split(" ")[0])); var expiry_date = date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear(); var temp = '
' +'
' +'
'+data.getOffersFromVaultResponse.vaultOfferDetails[i].title + '
'+data.getOffersFromVaultResponse.vaultOfferDetails[i].description +'
Expires on
'+expiry_date+'
' $('.offers-collected-container').append(temp); } } } }) .fail(function(error) { console.log("error in fetchtransactions api",error); }); }