mirror of
https://github.com/status-im/nimbus-gui.git
synced 2025-02-15 12:56:38 +00:00
feat: use recovery mechanism from redux
This commit is contained in:
parent
7ee2c047ee
commit
fe02c14efd
@ -2,10 +2,10 @@ 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 { useSelector } from 'react-redux'
|
||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
|
||||||
import { RootState } from '../../redux/store'
|
import { RootState } from '../../redux/store'
|
||||||
import LinkWithArrow from '../../components/General/LinkWithArrow'
|
import LinkWithArrow from '../../components/General/LinkWithArrow'
|
||||||
import { useEffect, useState } from 'react'
|
|
||||||
|
|
||||||
type ContinueButton = {
|
type ContinueButton = {
|
||||||
continueHandler: () => void
|
continueHandler: () => void
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Stack, YStack } from 'tamagui'
|
import { Stack, YStack } from 'tamagui'
|
||||||
import { Text } from '@status-im/components'
|
import { Text } from '@status-im/components'
|
||||||
import { useState } from 'react'
|
import { useSelector } from 'react-redux'
|
||||||
|
|
||||||
import KeyGenerationHeader from './KeyGenerationHeader/KeyGenerationHeader'
|
import KeyGenerationHeader from './KeyGenerationHeader/KeyGenerationHeader'
|
||||||
import RecoveryMechanism from './RecoveryMechanism/RecoveryMechanism'
|
import RecoveryMechanism from './RecoveryMechanism/RecoveryMechanism'
|
||||||
@ -8,13 +8,14 @@ import KeystoreFiles from './KeystoreFiles'
|
|||||||
import RecoveryPhrase from './RecoveryPhrase'
|
import RecoveryPhrase from './RecoveryPhrase'
|
||||||
import ConfirmRecoveryPhrase from './ConfirmRecoveryPhrase/ConfirmRecoveryPhrase'
|
import ConfirmRecoveryPhrase from './ConfirmRecoveryPhrase/ConfirmRecoveryPhrase'
|
||||||
import { BOTH_KEY_AND_RECOVERY, KEYSTORE_FILES, RECOVERY_PHRASE } from '../../../constants'
|
import { BOTH_KEY_AND_RECOVERY, KEYSTORE_FILES, RECOVERY_PHRASE } from '../../../constants'
|
||||||
|
import { RootState } from '../../../redux/store'
|
||||||
|
|
||||||
type KeyGenerationProps = {
|
type KeyGenerationProps = {
|
||||||
isConfirmPhraseStage: boolean
|
isConfirmPhraseStage: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const KeyGeneration = ({ isConfirmPhraseStage }: KeyGenerationProps) => {
|
const KeyGeneration = ({ isConfirmPhraseStage }: KeyGenerationProps) => {
|
||||||
const [recoveryMechanism, setRecoveryMechanism] = useState(KEYSTORE_FILES)
|
const { recoveryMechanism } = useSelector((state: RootState) => state.keyGeneration)
|
||||||
|
|
||||||
const isKeystoreFiles =
|
const isKeystoreFiles =
|
||||||
recoveryMechanism === KEYSTORE_FILES || recoveryMechanism === BOTH_KEY_AND_RECOVERY
|
recoveryMechanism === KEYSTORE_FILES || recoveryMechanism === BOTH_KEY_AND_RECOVERY
|
||||||
@ -22,20 +23,13 @@ const KeyGeneration = ({ isConfirmPhraseStage }: KeyGenerationProps) => {
|
|||||||
const isRecoveryPhrase =
|
const isRecoveryPhrase =
|
||||||
recoveryMechanism === RECOVERY_PHRASE || recoveryMechanism === BOTH_KEY_AND_RECOVERY
|
recoveryMechanism === RECOVERY_PHRASE || recoveryMechanism === BOTH_KEY_AND_RECOVERY
|
||||||
|
|
||||||
const handleRecMechanismChange = (value: string) => {
|
|
||||||
setRecoveryMechanism(value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<YStack space={'$2'} style={{ width: '100%', padding: '16px 32px', alignItems: 'start' }}>
|
<YStack space={'$2'} style={{ width: '100%', padding: '16px 32px', alignItems: 'start' }}>
|
||||||
{isConfirmPhraseStage && <ConfirmRecoveryPhrase />}
|
{isConfirmPhraseStage && <ConfirmRecoveryPhrase />}
|
||||||
{isConfirmPhraseStage === false && (
|
{isConfirmPhraseStage === false && (
|
||||||
<>
|
<>
|
||||||
<KeyGenerationHeader />
|
<KeyGenerationHeader />
|
||||||
<RecoveryMechanism
|
<RecoveryMechanism recoveryMechanism={recoveryMechanism} />
|
||||||
recoveryMechanism={recoveryMechanism}
|
|
||||||
handleRecMechanismChange={handleRecMechanismChange}
|
|
||||||
/>
|
|
||||||
<Stack style={{ margin: '30px 0' }}>
|
<Stack style={{ margin: '30px 0' }}>
|
||||||
<Text size={27} weight={'semibold'}>
|
<Text size={27} weight={'semibold'}>
|
||||||
4 Validators
|
4 Validators
|
||||||
|
@ -18,27 +18,23 @@ type Story = StoryObj<typeof meta>
|
|||||||
export const KeystoreFiles: Story = {
|
export const KeystoreFiles: Story = {
|
||||||
args: {
|
args: {
|
||||||
recoveryMechanism: KEYSTORE_FILES,
|
recoveryMechanism: KEYSTORE_FILES,
|
||||||
handleRecMechanismChange: () => {},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RecoveryPhrase: Story = {
|
export const RecoveryPhrase: Story = {
|
||||||
args: {
|
args: {
|
||||||
recoveryMechanism: RECOVERY_PHRASE,
|
recoveryMechanism: RECOVERY_PHRASE,
|
||||||
handleRecMechanismChange: () => {},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const BothKeystoreAndRecovery: Story = {
|
export const BothKeystoreAndRecovery: Story = {
|
||||||
args: {
|
args: {
|
||||||
recoveryMechanism: BOTH_KEY_AND_RECOVERY,
|
recoveryMechanism: BOTH_KEY_AND_RECOVERY,
|
||||||
handleRecMechanismChange: () => {},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export const WithoutRecMechanism: Story = {
|
export const WithoutRecMechanism: Story = {
|
||||||
args: {
|
args: {
|
||||||
recoveryMechanism: '',
|
recoveryMechanism: '',
|
||||||
handleRecMechanismChange: () => {},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,11 @@ import { BOTH_KEY_AND_RECOVERY, KEYSTORE_FILES, RECOVERY_PHRASE } from '../../..
|
|||||||
|
|
||||||
type RecoveryMechanismProps = {
|
type RecoveryMechanismProps = {
|
||||||
recoveryMechanism: string
|
recoveryMechanism: string
|
||||||
handleRecMechanismChange: (value: string) => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const cards = [RECOVERY_PHRASE, KEYSTORE_FILES, BOTH_KEY_AND_RECOVERY]
|
const cards = [RECOVERY_PHRASE, KEYSTORE_FILES, BOTH_KEY_AND_RECOVERY]
|
||||||
|
|
||||||
const RecoveryMechanism = ({
|
const RecoveryMechanism = ({ recoveryMechanism }: RecoveryMechanismProps) => {
|
||||||
recoveryMechanism,
|
|
||||||
handleRecMechanismChange,
|
|
||||||
}: RecoveryMechanismProps) => {
|
|
||||||
return (
|
return (
|
||||||
<YStack style={{ width: '100%' }}>
|
<YStack style={{ width: '100%' }}>
|
||||||
<Text size={19} weight={'semibold'}>
|
<Text size={19} weight={'semibold'}>
|
||||||
@ -22,12 +18,7 @@ const RecoveryMechanism = ({
|
|||||||
</Text>
|
</Text>
|
||||||
<XStack space={'$4'} style={{ justifyContent: 'space-between', marginTop: '40px' }}>
|
<XStack space={'$4'} style={{ justifyContent: 'space-between', marginTop: '40px' }}>
|
||||||
{cards.map(value => (
|
{cards.map(value => (
|
||||||
<RecoveryMechanismCard
|
<RecoveryMechanismCard key={value} value={value} recoveryMechanism={recoveryMechanism} />
|
||||||
key={value}
|
|
||||||
value={value}
|
|
||||||
recoveryMechanism={recoveryMechanism}
|
|
||||||
handleRecMechanismChange={handleRecMechanismChange}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</XStack>
|
</XStack>
|
||||||
</YStack>
|
</YStack>
|
||||||
|
@ -19,7 +19,6 @@ export const Selected: Story = {
|
|||||||
args: {
|
args: {
|
||||||
value: KEYSTORE_FILES,
|
value: KEYSTORE_FILES,
|
||||||
recoveryMechanism: KEYSTORE_FILES,
|
recoveryMechanism: KEYSTORE_FILES,
|
||||||
handleRecMechanismChange: () => {},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ export const NotSelected: Story = {
|
|||||||
args: {
|
args: {
|
||||||
value: KEYSTORE_FILES,
|
value: KEYSTORE_FILES,
|
||||||
recoveryMechanism: '',
|
recoveryMechanism: '',
|
||||||
handleRecMechanismChange: () => {},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +33,5 @@ export const WithoutValue: Story = {
|
|||||||
args: {
|
args: {
|
||||||
value: '',
|
value: '',
|
||||||
recoveryMechanism: KEYSTORE_FILES,
|
recoveryMechanism: KEYSTORE_FILES,
|
||||||
handleRecMechanismChange: () => {},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
import { Text } from '@status-im/components'
|
import { Text } from '@status-im/components'
|
||||||
|
import { useDispatch } from 'react-redux'
|
||||||
|
|
||||||
|
import { setRecoveryMechanism } from '../../../../redux/ValidatorOnboarding/KeyGeneration/slice'
|
||||||
|
|
||||||
type RecoveryMechanismProps = {
|
type RecoveryMechanismProps = {
|
||||||
value: string
|
value: string
|
||||||
recoveryMechanism: string
|
recoveryMechanism: string
|
||||||
handleRecMechanismChange: (value: string) => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const RecoveryMechanismCard = ({
|
const RecoveryMechanismCard = ({ value, recoveryMechanism }: RecoveryMechanismProps) => {
|
||||||
value,
|
const dispatch = useDispatch()
|
||||||
recoveryMechanism,
|
|
||||||
handleRecMechanismChange,
|
const handleRecMechanismChange = () => {
|
||||||
}: RecoveryMechanismProps) => {
|
dispatch(setRecoveryMechanism(value))
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@ -22,7 +26,7 @@ const RecoveryMechanismCard = ({
|
|||||||
width: '100%',
|
width: '100%',
|
||||||
height: '140px',
|
height: '140px',
|
||||||
}}
|
}}
|
||||||
onClick={() => handleRecMechanismChange(value)}
|
onClick={handleRecMechanismChange}
|
||||||
>
|
>
|
||||||
<Text size={15} weight={'semibold'}>
|
<Text size={15} weight={'semibold'}>
|
||||||
{value}
|
{value}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user