-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1071 from dis-moi/feat/triggerWelcomeBulle
feat(onboarding): trigger welcome bulle
- Loading branch information
Showing
4 changed files
with
57 additions
and
24 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 @@ | ||
import React, { Suspense } from 'react'; | ||
import { TriggerWelcomeBulle } from './withConnect'; | ||
|
||
const OnBoarding = React.lazy(() => | ||
import( | ||
/* webpackChunkName: "OnBoarding" */ 'app/profiles/App/OnBoarding/OnBoarding' | ||
) | ||
); | ||
|
||
interface LazyOnBoarding { | ||
isOnBoarding: boolean; | ||
triggerWelcomeBulle: TriggerWelcomeBulle; | ||
} | ||
|
||
const LazyOnBoarding = ({ | ||
isOnBoarding, | ||
triggerWelcomeBulle | ||
}: LazyOnBoarding) => { | ||
if (!isOnBoarding) return null; | ||
|
||
return ( | ||
<Suspense fallback={<>Chargement...</>}> | ||
<OnBoarding triggerWelcomeBulle={triggerWelcomeBulle} /> | ||
</Suspense> | ||
); | ||
}; | ||
|
||
export default LazyOnBoarding; |
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 |
---|---|---|
@@ -1,23 +1,4 @@ | ||
import React, { Suspense } from 'react'; | ||
import LazyOnBoarding from './LazyOnBoarding'; | ||
import withConnect from './withConnect'; | ||
|
||
const OnBoarding = React.lazy(() => | ||
import( | ||
/* webpackChunkName: "OnBoarding" */ 'app/profiles/App/OnBoarding/OnBoarding' | ||
) | ||
); | ||
|
||
const REDIRECTED_PATH = 'pk_campaign=installed'; | ||
export const isOnboarding = () => | ||
window.location.search.includes(REDIRECTED_PATH); | ||
|
||
const LazyOnBoarding = () => { | ||
if (!isOnboarding()) return null; | ||
|
||
return ( | ||
<Suspense fallback={<>Chargement...</>}> | ||
<OnBoarding /> | ||
</Suspense> | ||
); | ||
}; | ||
|
||
export default LazyOnBoarding; | ||
export default withConnect(LazyOnBoarding); |
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,16 @@ | ||
import { connect } from 'react-redux'; | ||
import { push } from 'connected-react-router'; | ||
import { ProfilesState } from '../../store/reducers'; | ||
|
||
const SEARCH_PATH = '?pk_campaign=installed'; | ||
|
||
const mapStateToProps = (state: ProfilesState) => ({ | ||
isOnBoarding: state.router.location.search === SEARCH_PATH | ||
}); | ||
|
||
export type TriggerWelcomeBulle = () => void; | ||
const mapDispatchToProps = { | ||
triggerWelcomeBulle: () => push(SEARCH_PATH + '-contributors-list') | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps); |