1
- /* eslint-disable react/no-multi-comp */
2
1
import React , { VFC } from 'react' ;
3
- import { WalletSetupStepLayoutRevamp , WalletTimelineSteps } from '@lace/core' ;
4
- import cn from 'classnames' ;
5
2
import { useRestoreWallet } from '../context' ;
6
- import {
7
- Box ,
8
- Card ,
9
- Flex ,
10
- RadioButtonGroup ,
11
- Text ,
12
- PaperwalletComponent as PaperWalletIcon ,
13
- MnemonicComponent as MnemonicWordsIcon
14
- } from '@input-output-hk/lace-ui-toolkit' ;
15
- import styles from './ChooseRestoreMethod.module.scss' ;
16
3
import { i18n } from '@lace/translation' ;
17
4
18
- import { RecoveryMethod } from '../../types' ;
19
5
import { Trans } from 'react-i18next' ;
20
6
import { useWalletOnboarding } from '../../walletOnboardingContext' ;
21
7
import { useAnalyticsContext } from '@providers' ;
8
+ import { ChooseRecoveryMethodBase } from '../../create-wallet/steps/ChooseRecoveryMethod' ;
22
9
23
10
const FAQ_URL = `${ process . env . FAQ_URL } ?question=what-is-paper-wallet` ;
24
11
@@ -33,106 +20,21 @@ export const ChooseRestoreMethod: VFC = () => {
33
20
} ;
34
21
35
22
return (
36
- < >
37
- < WalletSetupStepLayoutRevamp
38
- title = { i18n . t ( 'paperWallet.chooseRestoreMethod.title' ) }
39
- description = {
40
- < Trans
41
- i18nKey = "paperWallet.chooseRestoreMethod.description"
42
- components = { {
43
- a : (
44
- < a
45
- href = { FAQ_URL }
46
- target = "_blank"
47
- rel = "noopener noreferrer"
48
- data-testid = "faq-what-is-paper-wallet-url"
49
- />
50
- )
51
- } }
52
- />
53
- }
54
- onBack = { back }
55
- onNext = { handleNext }
56
- currentTimelineStep = { WalletTimelineSteps . CHOOSE_RECOVERY_METHOD }
57
- >
58
- < Flex flexDirection = "column" w = "$fill" h = "$fill" >
59
- < RadioButtonGroup
60
- selectedValue = { recoveryMethod }
61
- onValueChange = { ( value : RecoveryMethod ) => setRecoveryMethod ( value ) }
62
- className = { styles . noPadding }
63
- options = { [
64
- {
65
- value : 'mnemonic' ,
66
- label : i18n . t ( 'core.walletSetupStep.recoveryPhrase' ) ,
67
- render : ( { optionElement, onOptionClick } ) => (
68
- < Card . Outlined
69
- onClick = { ( ) => {
70
- void analytics . sendEventToPostHog ( postHogActions . restore . CHOOSE_RECOVERY_MODE_MNEMONIC_CLICK ) ;
71
- onOptionClick ( ) ;
72
- } }
73
- className = { cn ( {
74
- [ styles . selectedRestoreMethod ] : recoveryMethod === 'mnemonic' ,
75
- [ styles . optionCard ] : recoveryMethod !== 'mnemonic'
76
- } ) }
77
- >
78
- < Flex p = "$16" gap = "$24" justifyContent = "space-between" className = { styles . pointer } >
79
- < Flex flexDirection = "column" >
80
- < Flex mb = "$8" >
81
- < Text . Body . Normal weight = "$medium" color = "primary" data-testid = "mnemonic-words-label" >
82
- { optionElement }
83
- </ Text . Body . Normal >
84
- </ Flex >
85
- < Box pl = "$40" >
86
- < Text . Body . Normal weight = "$medium" color = "secondary" data-testid = "mnemonic-words-description" >
87
- { i18n . t ( 'paperWallet.chooseRecoveryMethod.mnemonicDescription' ) }
88
- </ Text . Body . Normal >
89
- </ Box >
90
- </ Flex >
91
- < Flex >
92
- < MnemonicWordsIcon className = { styles . restoreIcon } data-testid = "mnemonic-words-icon" />
93
- </ Flex >
94
- </ Flex >
95
- </ Card . Outlined >
96
- )
97
- } ,
98
- {
99
- value : 'paper' ,
100
- label : i18n . t ( 'paperWallet.chooseRestoreMethod.option.paper' ) ,
101
- render : ( { optionElement, onOptionClick } ) => (
102
- < Card . Outlined
103
- onClick = { ( ) => {
104
- void analytics . sendEventToPostHog ( postHogActions . restore . CHOOSE_RECOVERY_MODE_PAPER_CLICK ) ;
105
- onOptionClick ( ) ;
106
- } }
107
- className = { cn ( styles . paperWalletRadioGroupItem , {
108
- [ styles . selectedRestoreMethod ] : recoveryMethod === 'paper' ,
109
- [ styles . optionCard ] : recoveryMethod !== 'paper'
110
- } ) }
111
- >
112
- < Flex p = "$16" gap = "$24" justifyContent = "space-between" className = { styles . pointer } >
113
- < Flex flexDirection = "column" >
114
- < Flex mb = "$8" gap = "$8" alignItems = "center" >
115
- < Text . Body . Normal weight = "$medium" color = "primary" data-testid = "paper-wallet-label" >
116
- { optionElement }
117
- </ Text . Body . Normal >
118
- </ Flex >
119
- < Box pl = "$40" >
120
- < Text . Body . Normal weight = "$medium" color = "secondary" data-testid = "paper-wallet-description" >
121
- { i18n . t ( 'paperWallet.chooseRecoveryMethod.paperWallet.description' ) }
122
- </ Text . Body . Normal >
123
- </ Box >
124
- </ Flex >
125
- < Flex >
126
- < PaperWalletIcon className = { styles . restoreIcon } data-testid = "paper-wallet-icon" />
127
- </ Flex >
128
- </ Flex >
129
- </ Card . Outlined >
130
- )
131
- }
132
- ] }
133
- />
134
- </ Flex >
135
- </ WalletSetupStepLayoutRevamp >
136
- </ >
23
+ < ChooseRecoveryMethodBase
24
+ title = { i18n . t ( 'paperWallet.chooseRestoreMethod.title' ) }
25
+ description = {
26
+ < Trans
27
+ i18nKey = "paperWallet.chooseRestoreMethod.description"
28
+ components = { {
29
+ a : < a href = { FAQ_URL } target = "_blank" rel = "noopener noreferrer" data-testid = "faq-what-is-paper-wallet-url" />
30
+ } }
31
+ />
32
+ }
33
+ back = { back }
34
+ handleNext = { handleNext }
35
+ recoveryMethod = { recoveryMethod }
36
+ setRecoveryMethod = { setRecoveryMethod }
37
+ flow = "create"
38
+ />
137
39
) ;
138
40
} ;
0 commit comments