File size: 770 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import page, { type Callback } from '@automattic/calypso-router';
import AgencySignUp from 'calypso/jetpack-cloud/sections/agency-signup/primary/agency-signup';
import { partnerPortalBasePath } from 'calypso/lib/jetpack/paths';
import { getCurrentPartner } from 'calypso/state/partner-portal/partner/selectors';

export const requireNoPartnerRecordContext: Callback = ( context, next ) => {
	const state = context.store.getState();
	const partner = getCurrentPartner( state );

	// Users who already have a partner record should be redirected away from the signup form.
	if ( partner ) {
		page.redirect( partnerPortalBasePath() );
		return;
	}

	next();
};

export const signUpContext: Callback = ( context, next ) => {
	context.primary = <AgencySignUp />;
	next();
};