import React from 'react'
import PropTypes from 'prop-types'
import LoadingBolt from 'components/LoadingBolt'
import FormContainer from './FormContainer'
import Alias from './Alias'
import Autopilot from './Autopilot'
import Login from './Login'
import Signup from './Signup'
import NewWalletSeed from './NewWalletSeed'
import ReEnterSeed from './ReEnterSeed'
import NewWalletPassword from './NewWalletPassword'
import NewAezeedPassword from './NewAezeedPassword'
import styles from './Onboarding.scss'
const Onboarding = ({
onboarding: {
step,
alias,
autopilot,
startingLnd,
createWalletPassword,
seed,
aezeedPassword,
fetchingSeed
},
changeStep,
startLnd,
submitNewWallet,
aliasProps,
initWalletProps,
autopilotProps,
newWalletSeedProps,
newWalletPasswordProps,
newAezeedPasswordProps,
reEnterSeedProps
}) => {
const renderStep = () => {
switch (step) {
case 1:
return (
changeStep(2)}
>
)
case 2:
return (
changeStep(1)}
next={() => startLnd(alias, autopilot)}
>
)
case 3:
return (
)
case 4:
return (
{
// dont allow the user to move on if the confirmation password doesnt match the original password
if (newWalletPasswordProps.showCreateWalletPasswordConfirmationError) { return }
changeStep(5)
}}
>
)
case 5:
return (
changeStep(4)}
next={() => (initWalletProps.signupProps.signupForm.create ? changeStep(6) : console.log('import'))}
>
)
case 6:
return (
changeStep(5)}
next={() => changeStep(7)}
>
)
case 7:
return (
changeStep(6)}
next={() => {
// don't allow them to move on if they havent re-entered the seed correctly
if (!reEnterSeedProps.reEnterSeedChecker) { return }
changeStep(8)
}}
>
)
case 8:
return (
changeStep(6)}
next={() => {
// dont allow the user to move on if the confirmation password doesnt match the original password
if (newAezeedPasswordProps.showAezeedPasswordConfirmationError) { return }
submitNewWallet(createWalletPassword, seed, aezeedPassword)
}}
>
)
default:
return
}
}
if (startingLnd) { return }
if (fetchingSeed) { return }
return (
{renderStep()}
)
}
Onboarding.propTypes = {
onboarding: PropTypes.object.isRequired,
aliasProps: PropTypes.object.isRequired,
autopilotProps: PropTypes.object.isRequired,
initWalletProps: PropTypes.object.isRequired,
newWalletSeedProps: PropTypes.object.isRequired,
newWalletPasswordProps: PropTypes.object.isRequired,
newAezeedPasswordProps: PropTypes.object.isRequired,
reEnterSeedProps: PropTypes.object.isRequired,
changeStep: PropTypes.func.isRequired,
startLnd: PropTypes.func.isRequired,
submitNewWallet: PropTypes.func.isRequired
}
export default Onboarding