forked from NangoHQ/nango
-
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.
fix(demo): hide after complete (NangoHQ#1849)
## Describe your changes Fixes NAN-516 - Hide demo after completion This will only happen after refresh. I was going to animate it but definitely not worth the time at this stage. - Change the way we handle 404 and redirection Because I needed to wait for meta to be ready before making a redirection (I don't want to redirect to the demo if we already completed it) I needed to have a hook instead of a function. I split NotFound, Homepage, and handled the different scenario there. --- NB: I noticed this bug https://linear.app/nango/issue/NAN-568/fix-env-in-url-is-not-synced-to-cookie
- Loading branch information
1 parent
04eed88
commit 5214395
Showing
8 changed files
with
106 additions
and
41 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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useMeta } from '../hooks/useMeta'; | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
import { useStore } from '../store'; | ||
import { useEffect } from 'react'; | ||
|
||
export const Homepage: React.FC = () => { | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const showInteractiveDemo = useStore((state) => state.showInteractiveDemo); | ||
const env = useStore((state) => state.cookieValue); | ||
const { meta } = useMeta(); | ||
|
||
useEffect(() => { | ||
if (!meta) { | ||
return; | ||
} | ||
|
||
if (env === 'dev' && showInteractiveDemo && !meta.onboardingComplete) { | ||
navigate('/dev/interactive-demo'); | ||
return; | ||
} | ||
|
||
navigate(`/${env}/integrations`); | ||
}, [meta, location, env, navigate, showInteractiveDemo]); | ||
|
||
return null; | ||
}; |
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,36 @@ | ||
import { useLocation, useNavigate } from 'react-router-dom'; | ||
import { useStore } from '../store'; | ||
import { useEffect } from 'react'; | ||
|
||
const VALID_PATHS = [ | ||
'interactive-demo', | ||
'integration', | ||
'integrations', | ||
'syncs', | ||
'connections', | ||
'activity', | ||
'project-settings', | ||
'user-settings', | ||
'account-settings' | ||
]; | ||
|
||
export const NotFound: React.FC = () => { | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const showInteractiveDemo = useStore((state) => state.showInteractiveDemo); | ||
const env = useStore((state) => state.cookieValue); | ||
|
||
useEffect(() => { | ||
const pathSegments = location.pathname.split('/').filter(Boolean); | ||
// Add env in URL | ||
if (pathSegments[0] !== env && VALID_PATHS.includes(pathSegments[0])) { | ||
navigate(`/${env}/${pathSegments.join('/')}`); | ||
return; | ||
} | ||
|
||
navigate(`/${env}/integrations`); | ||
}, [location, env, navigate, showInteractiveDemo]); | ||
|
||
return null; | ||
}; |
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