Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setToken() {
// parse the url params from Keycloak
const params = this.getUrlParams();
if (typeof window !== "undefined" && params.access_token) {
const { keycloakAuthStore } = this.props;
keycloakAuthStore.setToken(params.access_token);
const previousRoute = localStorage.getItem("kc-redirected-from");
localStorage.removeItem("kc-redirected-from");
Router.pushRoute(previousRoute || "/");
}
}
function handleSearch({ keyCode, target }) {
// Send user to grid page when the enter key is pressed.
// The current search string will be appended to the URL as a query param.
if (keyCode === 13) {
const { value } = target;
const route = value === "" ? "/" : `/?search=${value}`;
Router.pushRoute(route);
}
}
handleTagSelected(tag, labels = ['TOPIC']) { // eslint-disable-line class-methods-use-this
const tagSt = `["${tag}"]`;
let treeSt = 'topics';
if (labels.includes('TOPIC')) {
treeSt = 'topics';
} else if (labels.includes('GEOGRAPHY')) {
treeSt = 'geographies';
} else if (labels.includes('DATA_TYPE')) {
treeSt = 'dataType';
}
Router.pushRoute('explore', { [treeSt]: tagSt });
}
onClick = () => {
const { navItem } = this.props;
if (this.hasSubNavItems) {
this.setState({ isSubNavOpen: !this.state.isSubNavOpen });
} else {
const path = this.linkPath;
Router.pushRoute(path, { slug: navItem.slug });
}
};