Skip to content

Commit

Permalink
feat(recovery): await email recovery link initialization and disable …
Browse files Browse the repository at this point in the history
…button for duration
  • Loading branch information
andy-haynes committed Mar 17, 2022
1 parent 8307bd9 commit 654e4cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const StyledContainer = styled(Container)`
export default ({
onClickSecureMyAccount,
email,
isInitializingRecoveryLink,
setEmail
}) => {
const [recoveryOption, setRecoveryOption] = useState('phrase');
Expand Down Expand Up @@ -100,7 +101,7 @@ export default ({
<FormButton
color='blue'
type='submit'
disabled={!isValidInput()}
disabled={!isValidInput() || isInitializingRecoveryLink}
trackingId='SR Click submit button'
data-test-id="submitSelectedRecoveryOption"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function SetupRecoveryImplicitAccountWrapper() {
const [verifyingEmailCode, setVerifyingEmailCode] = useState(false);
const [resendingEmailCode, setResendingEmailCode] = useState(false);
const [seedPhrasePublicKey, setSeedPhrasePublicKey] = useState(null);
const [isInitializingRecoveryLink, setIsInitializingRecoveryLink] = useState(false);

const handleInititalizeEmailRecoveryLink = async () => {
const passPhrase = await wallet.initializeRecoveryMethodNewImplicitAccount({ kind: 'email', detail: email });
Expand All @@ -36,6 +37,7 @@ export function SetupRecoveryImplicitAccountWrapper() {
return (
<SetupRecoveryImplicitAccount
email={email}
isInitializingRecoveryLink={isInitializingRecoveryLink}
setEmail={(email) => setEmail(email)}
onClickSecureMyAccount={async ({ recoveryOption }) => {
if (recoveryOption === 'phrase') {
Expand All @@ -44,8 +46,10 @@ export function SetupRecoveryImplicitAccountWrapper() {
dispatch(redirectTo('/setup-ledger-new-account'));
} else if (recoveryOption === 'email') {
Mixpanel.track('SR Select email');
setIsInitializingRecoveryLink(true);
await handleInititalizeEmailRecoveryLink();
setIsInitializingRecoveryLink(false);
setShowVerifyEmailCode(true);
handleInititalizeEmailRecoveryLink();
}
}}
/>
Expand Down

0 comments on commit 654e4cc

Please sign in to comment.