forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#23060 from koko57/fix/19496-2fa-steps-re…
…factor Fix/19496 2fa steps refactor
- Loading branch information
Showing
27 changed files
with
694 additions
and
579 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import {createContext} from 'react'; | ||
|
||
const AnimatedStepContext = createContext(); | ||
|
||
export default AnimatedStepContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React, {useState} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import AnimatedStepContext from './AnimatedStepContext'; | ||
import CONST from '../../CONST'; | ||
|
||
const propTypes = { | ||
children: PropTypes.node.isRequired, | ||
}; | ||
|
||
function AnimatedStepProvider({children}) { | ||
const [animationDirection, setAnimationDirection] = useState(CONST.ANIMATION_DIRECTION.IN); | ||
|
||
return <AnimatedStepContext.Provider value={{animationDirection, setAnimationDirection}}>{children}</AnimatedStepContext.Provider>; | ||
} | ||
|
||
AnimatedStepProvider.propTypes = propTypes; | ||
export default AnimatedStepProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {useContext} from 'react'; | ||
import AnimatedStepContext from './AnimatedStepContext'; | ||
|
||
function useAnimatedStepContext() { | ||
const context = useContext(AnimatedStepContext); | ||
if (!context) { | ||
throw new Error('useAnimatedStepContext must be used within an AnimatedStepContextProvider'); | ||
} | ||
return context; | ||
} | ||
|
||
export default useAnimatedStepContext; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,26 @@ | ||
import Onyx from 'react-native-onyx'; | ||
import ONYXKEYS from '../../ONYXKEYS'; | ||
import Navigation from '../Navigation/Navigation'; | ||
import ROUTES from '../../ROUTES'; | ||
|
||
/** | ||
* Clear 2FA data if the flow is interrupted without finishing | ||
*/ | ||
function clearTwoFactorAuthData() { | ||
Onyx.merge(ONYXKEYS.ACCOUNT, {recoveryCodes: '', twoFactorAuthSecretKey: ''}); | ||
Onyx.merge(ONYXKEYS.ACCOUNT, {recoveryCodes: '', twoFactorAuthSecretKey: '', twoFactorAuthStep: '', codesAreCopied: false}); | ||
} | ||
|
||
export { | ||
// eslint-disable-next-line import/prefer-default-export | ||
clearTwoFactorAuthData, | ||
}; | ||
function setTwoFactorAuthStep(twoFactorAuthStep) { | ||
Onyx.merge(ONYXKEYS.ACCOUNT, {twoFactorAuthStep}); | ||
} | ||
|
||
function setCodesAreCopied() { | ||
Onyx.merge(ONYXKEYS.ACCOUNT, {codesAreCopied: true}); | ||
} | ||
|
||
function quitAndNavigateBackToSettings() { | ||
clearTwoFactorAuthData(); | ||
Navigation.goBack(ROUTES.SETTINGS_SECURITY); | ||
} | ||
|
||
export {clearTwoFactorAuthData, setTwoFactorAuthStep, quitAndNavigateBackToSettings, setCodesAreCopied}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.