Skip to content

Commit

Permalink
Entrepreneur Signup: Fix unable to continue to site creation step in …
Browse files Browse the repository at this point in the history
…Entrepreneur Flow after login. (#90984)

* Fix incorrect step in Entrepreneur Flow after login or creating account.

* Rework login url.
  • Loading branch information
yansern committed May 22, 2024
1 parent 599fe0a commit e9e4cf2
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions client/landing/stepper/declarative-flow/entrepreneur-flow.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { getTracksAnonymousUserId } from '@automattic/calypso-analytics';
import { ENTREPRENEUR_FLOW } from '@automattic/onboarding';
import { useSelect, useDispatch } from '@wordpress/data';
import { addQueryArgs } from '@wordpress/url';
import { useEffect, useState } from 'react';
import { anonIdCache } from 'calypso/data/segmentaton-survey';
import { login } from 'calypso/lib/paths';
import { useSelector } from 'calypso/state';
import { isUserLoggedIn } from 'calypso/state/current-user/selectors';
import { useFlowLocale } from '../hooks/use-flow-locale';
import { USER_STORE, ONBOARD_STORE } from '../stores';
import { getLoginUrl } from '../utils/path';
import { recordSubmitStep } from './internals/analytics/record-submit-step';
import { STEPS } from './internals/steps';
import { ProcessingResult } from './internals/steps-repository/processing-step/constants';
Expand Down Expand Up @@ -49,26 +50,22 @@ const entrepreneurFlow: Flow = {
const [ isMigrationFlow, setIsMigrationFlow ] = useState( false );

const getEntrepreneurLoginUrl = () => {
let hasFlowParams = false;
const flowParams = new URLSearchParams();
const queryParams = new URLSearchParams();

if ( locale && locale !== 'en' ) {
flowParams.set( 'locale', locale );
hasFlowParams = true;
}

const redirectTarget =
`/setup/entrepreneur/create-site` +
( hasFlowParams ? encodeURIComponent( '?' + flowParams.toString() ) : '' );
const redirectTo = addQueryArgs(
`${ window.location.protocol }//${ window.location.host }/setup/entrepreneur/create-site`,
{
...Object.fromEntries( queryParams ),
}
);

const loginUrl = getLoginUrl( {
variationName: flowName,
redirectTo: redirectTarget,
const loginUrl = login( {
locale,
redirectTo,
oauth2ClientId: queryParams.get( 'client_id' ) || undefined,
} );

const flags = new URLSearchParams( window.location.search ).get( 'flags' );
return loginUrl + ( flags ? `&flags=${ flags }` : '' );
return loginUrl;
};

function submit( providedDependencies: ProvidedDependencies = {}, ...params: string[] ) {
Expand Down

0 comments on commit e9e4cf2

Please sign in to comment.