@@ -2,8 +2,7 @@ import {useIsFocused} from '@react-navigation/native';
2
2
import React , { forwardRef , useCallback , useEffect , useImperativeHandle , useRef , useState } from 'react' ;
3
3
import type { ForwardedRef } from 'react' ;
4
4
import { View } from 'react-native' ;
5
- import type { OnyxEntry } from 'react-native-onyx' ;
6
- import { withOnyx } from 'react-native-onyx' ;
5
+ import { useOnyx } from 'react-native-onyx' ;
7
6
import Button from '@components/Button' ;
8
7
import SafariFormWrapper from '@components/Form/SafariFormWrapper' ;
9
8
import FormHelpMessage from '@components/FormHelpMessage' ;
@@ -30,24 +29,11 @@ import * as User from '@userActions/User';
30
29
import CONST from '@src/CONST' ;
31
30
import type { TranslationPaths } from '@src/languages/types' ;
32
31
import ONYXKEYS from '@src/ONYXKEYS' ;
33
- import type { Account , Credentials , Session } from '@src/types/onyx' ;
34
32
import { isEmptyObject } from '@src/types/utils/EmptyObject' ;
35
33
import type ValidateCodeFormProps from './types' ;
36
34
37
- type BaseValidateCodeFormOnyxProps = {
38
- /** The details about the account that the user is signing in with */
39
- account : OnyxEntry < Account > ;
40
-
41
- /** The credentials of the person logging in */
42
- credentials : OnyxEntry < Credentials > ;
43
-
44
- /** Session info for the currently logged in user. */
45
- session : OnyxEntry < Session > ;
46
- } ;
47
-
48
35
type BaseValidateCodeFormProps = WithToggleVisibilityViewProps &
49
- ValidateCodeFormProps &
50
- BaseValidateCodeFormOnyxProps & {
36
+ ValidateCodeFormProps & {
51
37
/** Specifies autocomplete hints for the system, so it can provide autofill */
52
38
autoComplete : 'sms-otp' | 'one-time-code' ;
53
39
} ;
@@ -60,10 +46,10 @@ type ValidateCodeFormVariant = 'validateCode' | 'twoFactorAuthCode' | 'recoveryC
60
46
61
47
type FormError = Partial < Record < ValidateCodeFormVariant , TranslationPaths > > ;
62
48
63
- function BaseValidateCodeForm (
64
- { account, credentials , session , autoComplete , isUsingRecoveryCode , setIsUsingRecoveryCode , isVisible } : BaseValidateCodeFormProps ,
65
- forwardedRef : ForwardedRef < BaseValidateCodeFormRef > ,
66
- ) {
49
+ function BaseValidateCodeForm ( { autoComplete , isUsingRecoveryCode , setIsUsingRecoveryCode , isVisible } : BaseValidateCodeFormProps , forwardedRef : ForwardedRef < BaseValidateCodeFormRef > ) {
50
+ const [ account ] = useOnyx ( ONYXKEYS . ACCOUNT ) ;
51
+ const [ credentials ] = useOnyx ( ONYXKEYS . CREDENTIALS ) ;
52
+ const [ session ] = useOnyx ( ONYXKEYS . SESSION ) ;
67
53
const styles = useThemeStyles ( ) ;
68
54
const StyleUtils = useStyleUtils ( ) ;
69
55
const { translate} = useLocalize ( ) ;
@@ -345,10 +331,10 @@ function BaseValidateCodeForm(
345
331
) }
346
332
{ hasError && < FormHelpMessage message = { ErrorUtils . getLatestErrorMessage ( account ) } /> }
347
333
< PressableWithFeedback
334
+ key = { isUsingRecoveryCode . toString ( ) }
348
335
style = { [ styles . mt2 ] }
349
336
onPress = { switchBetween2faAndRecoveryCode }
350
337
hoverDimmingValue = { 1 }
351
- pressDimmingValue = { 0.2 }
352
338
disabled = { isValidateCodeFormSubmitting }
353
339
role = { CONST . ROLE . BUTTON }
354
340
accessibilityLabel = { isUsingRecoveryCode ? translate ( 'recoveryCodeForm.use2fa' ) : translate ( 'recoveryCodeForm.useRecoveryCode' ) }
@@ -422,12 +408,6 @@ function BaseValidateCodeForm(
422
408
423
409
BaseValidateCodeForm . displayName = 'BaseValidateCodeForm' ;
424
410
425
- export default withToggleVisibilityView (
426
- withOnyx < BaseValidateCodeFormProps , BaseValidateCodeFormOnyxProps > ( {
427
- account : { key : ONYXKEYS . ACCOUNT } ,
428
- credentials : { key : ONYXKEYS . CREDENTIALS } ,
429
- session : { key : ONYXKEYS . SESSION } ,
430
- } ) ( forwardRef ( BaseValidateCodeForm ) ) ,
431
- ) ;
411
+ export default withToggleVisibilityView ( forwardRef ( BaseValidateCodeForm ) ) ;
432
412
433
413
export type { BaseValidateCodeFormRef } ;
0 commit comments