Merge branch 'hn.validator-onboarding' of github.com:nimbus-gui/nimbus-gui into ia.responsive-css
This commit is contained in:
commit
d60eb4371a
|
@ -1,6 +1,9 @@
|
||||||
import { Stack, XStack } from 'tamagui'
|
import { Stack, XStack } from 'tamagui'
|
||||||
import { Button, InformationBox } from '@status-im/components'
|
import { Button, InformationBox } from '@status-im/components'
|
||||||
import { CloseCircleIcon } from '@status-im/icons'
|
import { CloseCircleIcon } from '@status-im/icons'
|
||||||
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
|
import { RootState } from '../../redux/store'
|
||||||
|
|
||||||
type ContinueButton = {
|
type ContinueButton = {
|
||||||
continueHandler: () => void
|
continueHandler: () => void
|
||||||
|
@ -8,16 +11,30 @@ type ContinueButton = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ContinueButton = ({ continueHandler, activeStep }: ContinueButton) => {
|
const ContinueButton = ({ continueHandler, activeStep }: ContinueButton) => {
|
||||||
|
const isCopyPastedPhrase = useSelector(
|
||||||
|
(state: RootState) => state.keyGeneration.isCopyPastedPhrase,
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<XStack style={{ width: '100%', marginTop: '16px', zIndex: 999, alignItems: 'center' }}>
|
<XStack style={{ width: '100%', marginTop: '16px', zIndex: 999, alignItems: 'center' }}>
|
||||||
<Stack style={{ width: '100%' }}>
|
<Stack style={{ width: '100%' }}>
|
||||||
|
{isCopyPastedPhrase && (
|
||||||
<InformationBox
|
<InformationBox
|
||||||
message="You have copy and pasted the entire Recovery Phrase. Please ensure you have secured it appropriately prior to continuing."
|
message="You have copy and pasted the entire Recovery Phrase. Please ensure you have secured it appropriately prior to continuing."
|
||||||
variant="error"
|
variant="error"
|
||||||
icon={<CloseCircleIcon size={20} />}
|
icon={<CloseCircleIcon size={20} />}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack style={{ width: '100%', alignItems: 'end', zIndex: 999, position: 'absolute' }}>
|
<Stack
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
alignItems: 'end',
|
||||||
|
zIndex: 999,
|
||||||
|
position: 'absolute',
|
||||||
|
marginTop: isCopyPastedPhrase ? '0px' : '40px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Button onPress={continueHandler} size={40}>
|
<Button onPress={continueHandler} size={40}>
|
||||||
{activeStep < 5 ? 'Continue' : 'Continue to Dashboard'}
|
{activeStep < 5 ? 'Continue' : 'Continue to Dashboard'}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -3,39 +3,13 @@ import { useDispatch, useSelector } from 'react-redux'
|
||||||
import wordlist from 'web-bip39/wordlists/english'
|
import wordlist from 'web-bip39/wordlists/english'
|
||||||
|
|
||||||
import { RootState } from '../../../../redux/store'
|
import { RootState } from '../../../../redux/store'
|
||||||
import { setMnemonic, setWord } from '../../../../redux/ValidatorOnboarding/KeyGeneration/slice'
|
import {
|
||||||
|
setIsCopyPastedPhrase,
|
||||||
|
setMnemonic,
|
||||||
|
setWord,
|
||||||
|
} from '../../../../redux/ValidatorOnboarding/KeyGeneration/slice'
|
||||||
import styles from './AutocompleteInput.module.css'
|
import styles from './AutocompleteInput.module.css'
|
||||||
|
|
||||||
const inputStyle = (index: number, isFocused: boolean) => {
|
|
||||||
const style = {
|
|
||||||
outline: 'none',
|
|
||||||
padding: `12px 16px 12px ${index + 1 < 10 ? '35px' : '45px'}`,
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isFocused) {
|
|
||||||
return {
|
|
||||||
...style,
|
|
||||||
border: '2px solid #4360DF',
|
|
||||||
backgroundColor: '#f1f2f4',
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return style
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const autocompleteContainerStyle = (isFocused: boolean) => {
|
|
||||||
if (isFocused) {
|
|
||||||
return {
|
|
||||||
borderTopLeftRadius: '24px',
|
|
||||||
borderTopRightRadius: '24px',
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
borderRadius: '24px',
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type AutocompleteInputProps = {
|
type AutocompleteInputProps = {
|
||||||
index: number
|
index: number
|
||||||
}
|
}
|
||||||
|
@ -63,10 +37,12 @@ const AutocompleteInput = ({ index }: AutocompleteInputProps) => {
|
||||||
dispatch(setWord({ index, word: value }))
|
dispatch(setWord({ index, word: value }))
|
||||||
} else if (mnemonicLength === 24) {
|
} else if (mnemonicLength === 24) {
|
||||||
dispatch(setMnemonic(mnemonic))
|
dispatch(setMnemonic(mnemonic))
|
||||||
|
dispatch(setIsCopyPastedPhrase(true))
|
||||||
} else {
|
} else {
|
||||||
for (let i = index; i < mnemonicLength + index; i++) {
|
for (let i = index; i < mnemonicLength + index; i++) {
|
||||||
dispatch(setWord({ index: i, word: mnemonic.shift() || '' }))
|
dispatch(setWord({ index: i, word: mnemonic.shift() || '' }))
|
||||||
}
|
}
|
||||||
|
dispatch(setIsCopyPastedPhrase(true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,3 +91,33 @@ const AutocompleteInput = ({ index }: AutocompleteInputProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AutocompleteInput
|
export default AutocompleteInput
|
||||||
|
|
||||||
|
const inputStyle = (index: number, isFocused: boolean) => {
|
||||||
|
const style = {
|
||||||
|
outline: 'none',
|
||||||
|
padding: `12px 16px 12px ${index + 1 < 10 ? '35px' : '45px'}`,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isFocused) {
|
||||||
|
return {
|
||||||
|
...style,
|
||||||
|
border: '2px solid #4360DF',
|
||||||
|
backgroundColor: '#f1f2f4',
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return style
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const autocompleteContainerStyle = (isFocused: boolean) => {
|
||||||
|
if (isFocused) {
|
||||||
|
return {
|
||||||
|
borderTopLeftRadius: '24px',
|
||||||
|
borderTopRightRadius: '24px',
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
borderRadius: '24px',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { YStack } from 'tamagui'
|
import { YStack } from 'tamagui'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate } from 'react-router-dom'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
import { useDispatch, useSelector } from 'react-redux'
|
||||||
|
|
||||||
import FormStepper from './FormStepper/FormStepper'
|
import FormStepper from './FormStepper/FormStepper'
|
||||||
import Titles from '../../components/General/Titles'
|
import Titles from '../../components/General/Titles'
|
||||||
|
@ -14,16 +15,23 @@ import Advisories from './Advisories/Advisories'
|
||||||
import ValidatorSetup from './ValidatorSetup/ValidatorSetup'
|
import ValidatorSetup from './ValidatorSetup/ValidatorSetup'
|
||||||
import ValidatorSetupInstall from './ValidatorSetup/ValidatorInstall'
|
import ValidatorSetupInstall from './ValidatorSetup/ValidatorInstall'
|
||||||
import ContinueButton from './ContinueButton'
|
import ContinueButton from './ContinueButton'
|
||||||
|
import { setIsCopyPastedPhrase } from '../../redux/ValidatorOnboarding/KeyGeneration/slice'
|
||||||
|
import { RootState } from '../../redux/store'
|
||||||
import './layoutGradient.css'
|
import './layoutGradient.css'
|
||||||
|
|
||||||
const ValidatorOnboarding = () => {
|
const ValidatorOnboarding = () => {
|
||||||
const [activeStep, setActiveStep] = useState(0)
|
const [activeStep, setActiveStep] = useState(0)
|
||||||
const [isConfirmPhraseStage, setIsConfirmPhraseStage] = useState(false)
|
const [isConfirmPhraseStage, setIsConfirmPhraseStage] = useState(false)
|
||||||
const [subStepValidatorSetup, setSubStepValidatorSetup] = useState(0)
|
const [subStepValidatorSetup, setSubStepValidatorSetup] = useState(0)
|
||||||
|
const isCopyPastedPhrase = useSelector(
|
||||||
|
(state: RootState) => state.keyGeneration.isCopyPastedPhrase,
|
||||||
|
)
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const dispatch = useDispatch()
|
||||||
|
|
||||||
const changeActiveStep = (step: number) => {
|
const changeActiveStep = (step: number) => {
|
||||||
setActiveStep(step)
|
setActiveStep(step)
|
||||||
|
removeCopyPastePhraseInfoBox()
|
||||||
}
|
}
|
||||||
|
|
||||||
const continueHandler = () => {
|
const continueHandler = () => {
|
||||||
|
@ -39,6 +47,13 @@ const ValidatorOnboarding = () => {
|
||||||
} else {
|
} else {
|
||||||
navigate('/')
|
navigate('/')
|
||||||
}
|
}
|
||||||
|
removeCopyPastePhraseInfoBox()
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeCopyPastePhraseInfoBox = () => {
|
||||||
|
if (isCopyPastedPhrase) {
|
||||||
|
dispatch(setIsCopyPastedPhrase(false))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||||
|
|
||||||
type KeyGenerationState = {
|
type KeyGenerationState = {
|
||||||
words: string[]
|
words: string[]
|
||||||
|
isCopyPastedPhrase: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type wordProps = {
|
type wordProps = {
|
||||||
|
@ -11,6 +12,7 @@ type wordProps = {
|
||||||
|
|
||||||
const initialState: KeyGenerationState = {
|
const initialState: KeyGenerationState = {
|
||||||
words: Array(24).fill(''),
|
words: Array(24).fill(''),
|
||||||
|
isCopyPastedPhrase: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const keyGenerationSlice = createSlice({
|
const keyGenerationSlice = createSlice({
|
||||||
|
@ -25,9 +27,16 @@ const keyGenerationSlice = createSlice({
|
||||||
setMnemonic: (state, action: PayloadAction<string[]>) => {
|
setMnemonic: (state, action: PayloadAction<string[]>) => {
|
||||||
state.words = action.payload
|
state.words = action.payload
|
||||||
},
|
},
|
||||||
|
setIsCopyPastedPhrase: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.isCopyPastedPhrase = action.payload
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
export const { setWord, setMnemonic } = keyGenerationSlice.actions
|
export const {
|
||||||
|
setWord,
|
||||||
|
setMnemonic,
|
||||||
|
setIsCopyPastedPhrase,
|
||||||
|
} = keyGenerationSlice.actions
|
||||||
|
|
||||||
export default keyGenerationSlice.reducer
|
export default keyGenerationSlice.reducer
|
||||||
|
|
Loading…
Reference in New Issue