Skip to content

Commit

Permalink
fix: link directly to nr1 instead of login page
Browse files Browse the repository at this point in the history
  • Loading branch information
aswanson-nr committed Sep 29, 2021
1 parent 32831db commit bf6604e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/InstallButton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/react';
import { Button, Link, Icon } from '@newrelic/gatsby-theme-newrelic';
Expand All @@ -7,7 +7,6 @@ import {
getGuidedInstallStackedNr1Url,
} from '../utils/get-pack-nr1-url';
import {
NR1_LOGIN_URL,
NR1_GUIDED_INSTALL_NERDLET,
NR1_PACK_DETAILS_NERDLET,
UTM_PARAMETERS,
Expand Down Expand Up @@ -52,14 +51,16 @@ const createInstallLink = (
? getGuidedInstallStackedNr1Url(nerdletId)
: getPackNr1Url(id, nerdletId);

const installUrl = new URL(hasUtmParameters ? NR1_SIGNUP_URL : NR1_LOGIN_URL);
const installUrl = new URL(hasUtmParameters ? NR1_SIGNUP_URL : platformUrl);
if (parameters) {
parameters.forEach((value, key) => {
installUrl.searchParams.set(key, value);
});
}

installUrl.searchParams.set('return_to', platformUrl);
if (hasUtmParameters) {
installUrl.searchParams.set('return_to', platformUrl);
}
return installUrl.href;
};

Expand All @@ -74,7 +75,12 @@ const hasComponent = (quickstart, key) =>
const InstallButton = ({ quickstart, location, ...props }) => {
const hasInstallableComponent = hasComponent(quickstart, 'installPlans');

const parameters = location.search && new URLSearchParams(location.search);
const [parameters, setParameters] = useState();
useEffect(() => {
if (location.search) {
setParameters(new URLSearchParams(location.search));
}
}, [location.search, setParameters]);

const hasGuidedInstall =
hasInstallableComponent &&
Expand Down

0 comments on commit bf6604e

Please sign in to comment.