-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Partner Portal: Simplify access gates redirection logic
- Loading branch information
1 parent
83b4602
commit 7a87322
Showing
5 changed files
with
45 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { useEffect } from 'react'; | ||
import page from 'page'; | ||
import { getQueryArg } from '@wordpress/url'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { ensurePartnerPortalReturnUrl } from 'calypso/jetpack-cloud/sections/partner-portal/utils'; | ||
|
||
/** | ||
* Redirect to the partner portal or a present "return" GET parameter given a certain condition. | ||
* | ||
* @param {boolean} redirect Whether to execute the redirect. | ||
* @returns {void} | ||
*/ | ||
export function useReturnUrl( redirect: boolean ): void { | ||
useEffect( () => { | ||
if ( redirect ) { | ||
const returnQuery = getQueryArg( window.location.href, 'return' ) as string; | ||
const returnUrl = ensurePartnerPortalReturnUrl( returnQuery ); | ||
|
||
page.redirect( returnUrl ); | ||
} | ||
}, [ redirect ] ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters