/**
 * External dependencies
 */
import CTA from 'GoogleComponents/notifications/cta';
import data from 'GoogleComponents/data';
import GenericError from 'GoogleComponents/notifications/generic-error';
import {
	activateOrDeactivateModule,
	showErrorNotification,
} from 'GoogleUtil';
/**
 * Internal dependencies
 */
import { getSiteKitAdminURL } from '../../../util';

const { __ } = wp.i18n;

const PageSpeedInsightsCTA = () => {
	const {
		active,
		setupComplete,
	} = googlesitekit.modules[ 'pagespeed-insights' ];

	const { canManageOptions } = googlesitekit.permissions;

	if ( ! canManageOptions && ! setupComplete ) {
		return null;
	}

	const handleSetUpClick = async () => {
		try {
			await activateOrDeactivateModule( data, 'pagespeed-insights', true );

			window.location.assign(
				getSiteKitAdminURL(
					'googlesitekit-dashboard',
					{
						notification: 'authentication_success',
						slug: 'pagespeed-insights',
					},
				)
			);
		} catch ( err ) {
			showErrorNotification( GenericError, {
				id: 'pagespeed-insights-setup-error',
				title: __( 'Internal Server Error', 'google-site-kit' ),
				description: err.message,
				format: 'small',
				type: 'win-error',
			} );
		}
	};

	return (
		<div className="
			mdc-layout-grid__cell
			mdc-layout-grid__cell--span-12
		">
			<CTA
				title={ ! setupComplete && active ?
					__( 'Complete PageSpeed Insights activation. ', 'google-site-kit' ) :
					__( 'Activate PageSpeed Insights. ', 'google-site-kit' )
				}
				description={ __( 'Google PageSpeed Insights gives you metrics about performance, accessibility, SEO and PWA.', 'google-site-kit' ) }
				ctaLink={ '#' }
				ctaLabel={ ! setupComplete && active ?
					__( 'Complete activation', 'google-site-kit' ) :
					__( 'Activate PageSpeed Insights', 'google-site-kit' )
				}
				onClick={ handleSetUpClick }
			/>
		</div>
	);
};

export default PageSpeedInsightsCTA;

@@ -323,31 +323,25 @@
 rt %7B get
-SiteKitAdminURL
+ReAuthUrl
  %7D from 
@@ -755,17 +755,16 @@
 true );%0A
-%0A
 %09%09%09windo
@@ -777,137 +777,24 @@
 tion
-.assign(%0A%09%09%09%09getSiteKitAdminURL(%0A%09%09%09%09%09'googlesitekit-dashboard',%0A%09%09%09%09%09%7B%0A%09%09%09%09%09%09notification: 'authentication_success',%0A%09%09%09%09%09%09slug:
+ = getReAuthUrl(
  'pa
@@ -814,27 +814,9 @@
 hts'
-,%0A%09%09%09%09%09%7D,%0A%09%09%09%09)%0A%09%09%09
+ 
 );%0A%09

refactor PageSpeedInsightsCTA to use reAuthUrl for consistency