|
|
@ -5,6 +5,7 @@ import { compose } from 'redux' |
|
|
|
import { translate } from 'react-i18next' |
|
|
|
import { connect } from 'react-redux' |
|
|
|
import styled from 'styled-components' |
|
|
|
import IconCross from 'icons/Cross' |
|
|
|
|
|
|
|
import type { T } from 'types/common' |
|
|
|
import type { OnboardingState } from 'reducers/onboarding' |
|
|
@ -20,6 +21,8 @@ import { |
|
|
|
updateGenuineCheck, |
|
|
|
isLedgerNano, |
|
|
|
flowType, |
|
|
|
relaunchOnboarding, |
|
|
|
onboardingRelaunchedSelector, |
|
|
|
} from 'reducers/onboarding' |
|
|
|
import { getCurrentDevice } from 'reducers/devices' |
|
|
|
|
|
|
@ -54,6 +57,7 @@ const STEPS = { |
|
|
|
|
|
|
|
const mapStateToProps = state => ({ |
|
|
|
hasCompletedOnboarding: state.settings.hasCompletedOnboarding, |
|
|
|
onboardingRelaunched: onboardingRelaunchedSelector(state), |
|
|
|
onboarding: state.onboarding, |
|
|
|
settings: state.settings, |
|
|
|
getCurrentDevice: getCurrentDevice(state), |
|
|
@ -66,11 +70,13 @@ const mapDispatchToProps = { |
|
|
|
jumpStep, |
|
|
|
unlock, |
|
|
|
openModal, |
|
|
|
relaunchOnboarding, |
|
|
|
} |
|
|
|
|
|
|
|
type Props = { |
|
|
|
t: T, |
|
|
|
hasCompletedOnboarding: boolean, |
|
|
|
onboardingRelaunched: boolean, |
|
|
|
saveSettings: Function, |
|
|
|
onboarding: OnboardingState, |
|
|
|
settings: SettingsState, |
|
|
@ -80,6 +86,7 @@ type Props = { |
|
|
|
getCurrentDevice: Function, |
|
|
|
unlock: Function, |
|
|
|
openModal: string => void, |
|
|
|
relaunchOnboarding: boolean => void, |
|
|
|
} |
|
|
|
|
|
|
|
export type StepProps = { |
|
|
@ -99,10 +106,33 @@ export type StepProps = { |
|
|
|
flowType: Function, |
|
|
|
} |
|
|
|
|
|
|
|
const CloseContainer = styled(Box).attrs({ |
|
|
|
p: 4, |
|
|
|
color: 'fog', |
|
|
|
})` |
|
|
|
cursor: pointer; |
|
|
|
position: absolute; |
|
|
|
top: 0; |
|
|
|
right: 0; |
|
|
|
z-index: 1; |
|
|
|
|
|
|
|
&:hover { |
|
|
|
color: ${p => p.theme.colors.grey}; |
|
|
|
} |
|
|
|
|
|
|
|
&:active { |
|
|
|
color: ${p => p.theme.colors.dark}; |
|
|
|
} |
|
|
|
` |
|
|
|
|
|
|
|
class Onboarding extends PureComponent<Props> { |
|
|
|
getDeviceInfo = () => this.props.getCurrentDevice |
|
|
|
cancelRelaunch = () => { |
|
|
|
this.props.relaunchOnboarding(false) |
|
|
|
} |
|
|
|
finish = () => { |
|
|
|
this.props.saveSettings({ hasCompletedOnboarding: true }) |
|
|
|
this.props.relaunchOnboarding(false) |
|
|
|
setTimeout(() => { |
|
|
|
this.props.openModal(MODAL_DISCLAIMER) |
|
|
|
}, MODAL_DISCLAIMER_DELAY) |
|
|
@ -119,17 +149,14 @@ class Onboarding extends PureComponent<Props> { |
|
|
|
|
|
|
|
render() { |
|
|
|
const { |
|
|
|
hasCompletedOnboarding, |
|
|
|
onboarding, |
|
|
|
prevStep, |
|
|
|
nextStep, |
|
|
|
jumpStep, |
|
|
|
settings, |
|
|
|
t, |
|
|
|
onboardingRelaunched, |
|
|
|
} = this.props |
|
|
|
if (hasCompletedOnboarding) { |
|
|
|
return null |
|
|
|
} |
|
|
|
|
|
|
|
const StepComponent = STEPS[onboarding.stepName] |
|
|
|
const step = onboarding.steps[onboarding.stepIndex] |
|
|
@ -159,6 +186,11 @@ class Onboarding extends PureComponent<Props> { |
|
|
|
return ( |
|
|
|
<Container> |
|
|
|
{step.options.showBreadcrumb && <OnboardingBreadcrumb />} |
|
|
|
{onboardingRelaunched ? ( |
|
|
|
<CloseContainer onClick={this.cancelRelaunch}> |
|
|
|
<IconCross size={16} /> |
|
|
|
</CloseContainer> |
|
|
|
) : null} |
|
|
|
<StepContainer> |
|
|
|
<StepComponent {...stepProps} /> |
|
|
|
</StepContainer> |
|
|
|