@ -8,9 +8,9 @@ type Step = {
external ? : boolean ,
external ? : boolean ,
label ? : string ,
label ? : string ,
options : {
options : {
showFooter : boolean ,
showBackground : boolean ,
showBreadcrumb : boolean ,
showBreadcrumb : boolean ,
relaunchSkip ? : boolean ,
alreadyInitSkip ? : boolean ,
} ,
} ,
}
}
@ -28,10 +28,11 @@ export type OnboardingState = {
} ,
} ,
isLedgerNano : boolean | null ,
isLedgerNano : boolean | null ,
flowType : string ,
flowType : string ,
onboardingRelaunched ? : boolean ,
}
}
const s tate: OnboardingState = {
const initialS tate: OnboardingState = {
stepIndex : 0 , // FIXME is this used at all? dup with stepName?
stepIndex : 0 ,
stepName : SKIP_ONBOARDING ? 'analytics' : 'start' ,
stepName : SKIP_ONBOARDING ? 'analytics' : 'start' ,
genuine : {
genuine : {
pinStepPass : false ,
pinStepPass : false ,
@ -43,13 +44,12 @@ const state: OnboardingState = {
} ,
} ,
isLedgerNano : null ,
isLedgerNano : null ,
flowType : '' ,
flowType : '' ,
onboardingRelaunched : false ,
steps : [
steps : [
{
{
name : 'start' ,
name : 'start' ,
external : true ,
external : true ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : false ,
showBreadcrumb : false ,
} ,
} ,
} ,
} ,
@ -57,8 +57,6 @@ const state: OnboardingState = {
name : 'init' ,
name : 'init' ,
external : true ,
external : true ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : false ,
showBreadcrumb : false ,
} ,
} ,
} ,
} ,
@ -66,8 +64,6 @@ const state: OnboardingState = {
name : 'noDevice' ,
name : 'noDevice' ,
external : true ,
external : true ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : false ,
showBreadcrumb : false ,
} ,
} ,
} ,
} ,
@ -75,8 +71,6 @@ const state: OnboardingState = {
name : 'selectDevice' ,
name : 'selectDevice' ,
label : 'onboarding:breadcrumb.selectDevice' ,
label : 'onboarding:breadcrumb.selectDevice' ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : true ,
showBreadcrumb : true ,
} ,
} ,
} ,
} ,
@ -84,26 +78,22 @@ const state: OnboardingState = {
name : 'selectPIN' ,
name : 'selectPIN' ,
label : 'onboarding:breadcrumb.selectPIN' ,
label : 'onboarding:breadcrumb.selectPIN' ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : true ,
showBreadcrumb : true ,
alreadyInitSkip : true ,
} ,
} ,
} ,
} ,
{
{
name : 'writeSeed' ,
name : 'writeSeed' ,
label : 'onboarding:breadcrumb.writeSeed' ,
label : 'onboarding:breadcrumb.writeSeed' ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : true ,
showBreadcrumb : true ,
alreadyInitSkip : true ,
} ,
} ,
} ,
} ,
{
{
name : 'genuineCheck' ,
name : 'genuineCheck' ,
label : 'onboarding:breadcrumb.genuineCheck' ,
label : 'onboarding:breadcrumb.genuineCheck' ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : true ,
showBreadcrumb : true ,
} ,
} ,
} ,
} ,
@ -111,26 +101,22 @@ const state: OnboardingState = {
name : 'setPassword' ,
name : 'setPassword' ,
label : 'onboarding:breadcrumb.setPassword' ,
label : 'onboarding:breadcrumb.setPassword' ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : true ,
showBreadcrumb : true ,
relaunchSkip : true ,
} ,
} ,
} ,
} ,
{
{
name : 'analytics' ,
name : 'analytics' ,
label : 'onboarding:breadcrumb.analytics' ,
label : 'onboarding:breadcrumb.analytics' ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : true ,
showBreadcrumb : true ,
relaunchSkip : true ,
} ,
} ,
} ,
} ,
{
{
name : 'finish' ,
name : 'finish' ,
external : true ,
external : true ,
options : {
options : {
showFooter : false ,
showBackground : true ,
showBreadcrumb : false ,
showBreadcrumb : false ,
} ,
} ,
} ,
} ,
@ -149,7 +135,7 @@ const handlers = {
}
}
return { ... state , stepName : state . steps [ index + 1 ] . name , stepIndex : index + 1 }
return { ... state , stepName : state . steps [ index + 1 ] . name , stepIndex : index + 1 }
} ,
} ,
ONBOARDING_PREV_STEP : state => {
ONBOARDING_PREV_STEP : ( state : OnboardingState ) => {
const step = state . steps . find ( step => step . name === state . stepName )
const step = state . steps . find ( step => step . name === state . stepName )
if ( ! step ) {
if ( ! step ) {
return state
return state
@ -160,7 +146,7 @@ const handlers = {
}
}
return { ... state , stepName : state . steps [ index - 1 ] . name , stepIndex : index - 1 }
return { ... state , stepName : state . steps [ index - 1 ] . name , stepIndex : index - 1 }
} ,
} ,
ONBOARDING_JUMP_STEP : ( state , { payload : stepName } ) => {
ONBOARDING_JUMP_STEP : ( state : OnboardingState , { payload : stepName } ) => {
const step = state . steps . find ( step => step . name === stepName )
const step = state . steps . find ( step => step . name === stepName )
if ( ! step ) {
if ( ! step ) {
return state
return state
@ -169,25 +155,30 @@ const handlers = {
return { ... state , stepName : step . name , stepIndex : index }
return { ... state , stepName : step . name , stepIndex : index }
} ,
} ,
UPDATE_GENUINE_CHECK : ( state , { payload : obj } ) => ( {
UPDATE_GENUINE_CHECK : ( state : OnboardingState , { payload : obj } ) => ( {
... state ,
... state ,
genuine : {
genuine : {
... state . genuine ,
... state . genuine ,
... obj ,
... obj ,
} ,
} ,
} ) ,
} ) ,
ONBOARDING_SET_FLOW_TYPE : ( state , { payload : flowType } ) => ( {
ONBOARDING_SET_FLOW_TYPE : ( state : OnboardingState , { payload : flowType } ) => ( {
... state ,
... state ,
flowType ,
flowType ,
} ) ,
} ) ,
ONBOARDING_SET_DEVICE_TYPE : ( state , { payload : isLedgerNano } ) => ( {
ONBOARDING_SET_DEVICE_TYPE : ( state : OnboardingState , { payload : isLedgerNano } ) => ( {
... state ,
... state ,
isLedgerNano ,
isLedgerNano ,
} ) ,
} ) ,
ONBOARDING_RELAUNCH : (
state : OnboardingState ,
{ payload : onboardingRelaunched } : { payload : $Shape < OnboardingState > } ,
) => ( { ... initialState , ... onboardingRelaunched } ) ,
}
}
export default handleActions ( handlers , state )
export default handleActions ( handlers , initialS tate)
export const relaunchOnboarding = createAction ( 'ONBOARDING_RELAUNCH' )
export const nextStep = createAction ( 'ONBOARDING_NEXT_STEP' )
export const nextStep = createAction ( 'ONBOARDING_NEXT_STEP' )
export const prevStep = createAction ( 'ONBOARDING_PREV_STEP' )
export const prevStep = createAction ( 'ONBOARDING_PREV_STEP' )
export const jumpStep = createAction ( 'ONBOARDING_JUMP_STEP' )
export const jumpStep = createAction ( 'ONBOARDING_JUMP_STEP' )