$(document).ready(function () { $('#deactivateAccount').off('click').on('click', function (e) { e.preventDefault(); $('#deactivateProfileModal').modal('show'); }); hasDeactivateRequest(); $('#deactivateYesBtn').on('click', function () { $('#deactivateProfileModal').modal('hide'); showLoader(); const payload = { "ricnt_User@odata.bind": `/contacts(${$('#user-id').text().trim()})`, ricnt_requesteddate: new Date().toISOString(), ricnt_requeststatus: 403540000 }; apiService.postItem("ricnt_riuserdeactivationrequests", payload) .then((res, status, xhr) => { disableDeactivateMenu(); hideLoader(); // Show Bootstrap modal instead of toast $('#deactivateSuccessModal').modal('show'); }) .catch((error) => { hideLoader(); showErrorToast("Failed to deactivate account"); }); }); const logoutUrl = `https://reddyiceconnect.ciamlogin.com/40e4311e-4801-4469-b203-50eb600d6e4c/oauth2/v2.0/logout?p=${$("#user-flow-name").val()}&post_logout_redirect_uri=${window.location.origin}/Account/Login/LogOff?returnUrl=%2FCP-Customer-Dashboard%2F`; $('#log-out').attr('href', logoutUrl); }); function hasDeactivateRequest() { apiService.getItems(`ricnt_riuserdeactivationrequests?$select=ricnt_requeststatus&$expand=ricnt_User($select=contactid)&$filter=ricnt_User/contactid eq '${$('#user-id').text().trim()}'`) .then(async (data) => { const hasRequested = data.value.some(r => r.ricnt_requeststatus === 403540000); // Requested status if (hasRequested) { disableDeactivateMenu(); } }) .catch((error) => { console.error("API error", error); }); } function disableDeactivateMenu() { $('#deactivateAccount') .addClass('disabled') .attr('aria-disabled', 'true') .css({ pointerEvents: 'none', color: 'gray' }); } //hide add/remove location in all pages except customer dashboard $(document).ready(function () { if (window.location.pathname !== "/CP-Customer-Dashboard/") { $("#account-box").children().hide(); } else { $("#account-box").parents(".header-top").addClass("customer-dashboard-account-box") } });