forked from Sage-Bionetworks/synapse-web-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PORTALS-2836: redirect the ELITE program page to the ELITE portal
- Loading branch information
1 parent
2e1c9c1
commit 6a6e016
Showing
4 changed files
with
47 additions
and
0 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
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,23 @@ | ||
import { useLocation } from 'react-router-dom' | ||
|
||
export type RedirectToURLProps = { | ||
toURL: string | ||
search?: string | ||
} | ||
|
||
/** | ||
* Allows us to use react-router's Redirect as a portal component without losing the query params. | ||
* @param props | ||
* @returns | ||
*/ | ||
export default function RedirectToURL(props: RedirectToURLProps) { | ||
const { search: currentSearch } = useLocation() | ||
|
||
const { toURL, search } = props | ||
const isSearchMatch = | ||
search == undefined ? true : `?${search}` == currentSearch | ||
|
||
if (isSearchMatch) { | ||
window.location.replace(toURL) | ||
} | ||
} |
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