cancel button fix

by dgrebb

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js"></script>
<button onclick="handleOverlayConfirmEvent(event);">click</button>

JavaScript

// redirect lookup uses flavor to address url
const redirectLookup = {
	r360: {
  	url: {
    	prod: "http://google.com",
      nonprod"http://stg.google.com"
    }
  }
};

// function check window.location === www.xfinity.com;

function getRedirectUrl(flavor) {
	var environment = getEnvironment();
  return redirectLookup[flavor].url[environment];
}

function handleOverlayConfirmEvent(event) {
  if (event.type === "click") {
    const learn = window.localStorage && JSON.parse(window.localStorage.getItem('learn'));
    const affiliate = "r360"; // get the combination of affiliate/channel and pass those to the lookup
    // if affiliate is RETAIL_360 || RETAIL_360-TEST do redirect logic based on frameworkconfig API lookup
    var redirectUrl = _.get(learn, 'userContext.AgentContext.RedirectUrl', getRedirectUrl(affiliate)); // set the redirect from userContext if it is available, otherwise use the affiliate/channel combination and get the redirect from the lookup object
    if(redirectUrl){
      console.log(redirectUrl);
      window.location.href = redirectUrl;
    }
  }
};