Skip to content

Commit

Permalink
fix: #2451 land on page not found bug (#2462)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pham Hai Duong authored Aug 25, 2020
1 parent aaf9bfe commit 0d41e8d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions packages/admin-portal/src/core/private-route-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ export const PrivateRouteWrapper: React.FunctionComponent<PrivateRouteWrapperPro
const { connectSession, connectInternalRedirect } = useReapitConnect(reapitConnectBrowserSession)
const location = useLocation()
const currentUri = `${location.pathname}${location.search}`
const isRoot = connectInternalRedirect === '/'
const isRoot = connectInternalRedirect === '/?' || connectInternalRedirect === '/'

if (!connectSession) {
return null
}

if (
(connectInternalRedirect && currentUri !== connectInternalRedirect) ||
(currentUri === connectInternalRedirect && isRoot)
) {
const redirectUri = isRoot ? Routes.APPROVALS : connectInternalRedirect
return <Redirect to={redirectUri} />
if (isRoot) {
return <Redirect to={Routes.APPROVALS} />
}

if (connectInternalRedirect && currentUri !== connectInternalRedirect) {
return <Redirect to={connectInternalRedirect} />
}

return (
Expand Down
14 changes: 7 additions & 7 deletions packages/developer-portal/src/core/private-route-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ export const PrivateRouteWrapper: React.FunctionComponent<PrivateRouteWrapperPro
const { connectSession, connectInternalRedirect } = useReapitConnect(reapitConnectBrowserSession)
const location = useLocation()
const currentUri = `${location.pathname}${location.search}`
const isRoot = connectInternalRedirect === '/'
const isRoot = connectInternalRedirect === '/?' || connectInternalRedirect === '/'

if (!connectSession) {
return null
}

if (
(connectInternalRedirect && currentUri !== connectInternalRedirect) ||
(currentUri === connectInternalRedirect && isRoot)
) {
const redirectUri = connectInternalRedirect === '/' ? Routes.APPS : connectInternalRedirect
return <Redirect to={redirectUri} />
if (isRoot) {
return <Redirect to={Routes.APPS} />
}

if (connectInternalRedirect && currentUri !== connectInternalRedirect) {
return <Redirect to={connectInternalRedirect} />
}

const hasReadWelcome = Boolean(getCookieString(COOKIE_DEVELOPER_FIRST_TIME_LOGIN_COMPLETE))
Expand Down
14 changes: 7 additions & 7 deletions packages/marketplace/src/core/private-route-wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ export const PrivateRouteWrapper: React.FunctionComponent<PrivateRouteWrapperPro
const { connectSession, connectInternalRedirect } = useReapitConnect(reapitConnectBrowserSession)
const location = useLocation()
const currentUri = `${location.pathname}${location.search}`
const isRoot = connectInternalRedirect === '/'
const isRoot = connectInternalRedirect === '/?' || connectInternalRedirect === '/'

if (!connectSession) {
return null
}

if (
(connectInternalRedirect && currentUri !== connectInternalRedirect) ||
(currentUri === connectInternalRedirect && isRoot)
) {
const redirectUri = connectInternalRedirect === '/' ? Routes.INSTALLED_APPS : connectInternalRedirect
return <Redirect to={redirectUri} />
if (isRoot) {
return <Redirect to={Routes.APPS} />
}

if (connectInternalRedirect && currentUri !== connectInternalRedirect) {
return <Redirect to={connectInternalRedirect} />
}

return (
Expand Down

0 comments on commit 0d41e8d

Please sign in to comment.