From 147dcbc576d8830778de8ad507b2e36f0480a20b Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 15 Oct 2024 13:09:09 +0800 Subject: [PATCH 1/3] fix unlink success isn't translated --- src/pages/signin/LoginForm/BaseLoginForm.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/signin/LoginForm/BaseLoginForm.tsx b/src/pages/signin/LoginForm/BaseLoginForm.tsx index f3df5ebfb0b5..23c4d09e4a64 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.tsx +++ b/src/pages/signin/LoginForm/BaseLoginForm.tsx @@ -62,6 +62,7 @@ function BaseLoginForm({account, login, onLoginChanged, closeAccount, blurOnSubm const isFocused = useIsFocused(); const isLoading = useRef(false); const {shouldUseNarrowLayout, isInNarrowPaneModal} = useResponsiveLayout(); + const accountMessage = account?.message === 'unlinkLoginForm.succesfullyUnlinkedLogin' ? translate(account.message) : account?.message ?? ''; /** * Validate the input value and set the error for formError @@ -276,7 +277,7 @@ function BaseLoginForm({account, login, onLoginChanged, closeAccount, blurOnSubm style={[styles.mv2]} type="success" // eslint-disable-next-line @typescript-eslint/naming-convention,@typescript-eslint/prefer-nullish-coalescing - messages={{0: closeAccount?.success ? closeAccount.success : account?.message || ''}} + messages={{0: closeAccount?.success ? closeAccount.success : accountMessage}} /> )} { From 36157b36df34f7ff5b59b98bf16b8981f3f483b7 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 15 Oct 2024 13:14:27 +0800 Subject: [PATCH 2/3] migrate to useonyx --- src/pages/signin/LoginForm/BaseLoginForm.tsx | 26 +++++--------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/pages/signin/LoginForm/BaseLoginForm.tsx b/src/pages/signin/LoginForm/BaseLoginForm.tsx index 23c4d09e4a64..2e762224f904 100644 --- a/src/pages/signin/LoginForm/BaseLoginForm.tsx +++ b/src/pages/signin/LoginForm/BaseLoginForm.tsx @@ -3,8 +3,7 @@ import {Str} from 'expensify-common'; import type {ForwardedRef} from 'react'; import React, {forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react'; import {InteractionManager, View} from 'react-native'; -import {withOnyx} from 'react-native-onyx'; -import type {OnyxEntry} from 'react-native-onyx'; +import {useOnyx} from 'react-native-onyx'; import DotIndicatorMessage from '@components/DotIndicatorMessage'; import FormAlertWithSubmitButton from '@components/FormAlertWithSubmitButton'; import AppleSignIn from '@components/SignInButtons/AppleSignIn'; @@ -34,24 +33,16 @@ import CONFIG from '@src/CONFIG'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {CloseAccountForm} from '@src/types/form'; -import type {Account} from '@src/types/onyx'; import htmlDivElementRef from '@src/types/utils/htmlDivElementRef'; import viewRef from '@src/types/utils/viewRef'; import type LoginFormProps from './types'; import type {InputHandle} from './types'; -type BaseLoginFormOnyxProps = { - /** The details about the account that the user is signing in with */ - account: OnyxEntry; +type BaseLoginFormProps = WithToggleVisibilityViewProps & LoginFormProps; - /** Message to display when user successfully closed their account */ - closeAccount: OnyxEntry; -}; - -type BaseLoginFormProps = WithToggleVisibilityViewProps & BaseLoginFormOnyxProps & LoginFormProps; - -function BaseLoginForm({account, login, onLoginChanged, closeAccount, blurOnSubmit = false, isVisible}: BaseLoginFormProps, ref: ForwardedRef) { +function BaseLoginForm({login, onLoginChanged, blurOnSubmit = false, isVisible}: BaseLoginFormProps, ref: ForwardedRef) { + const [account] = useOnyx(ONYXKEYS.ACCOUNT); + const [closeAccount] = useOnyx(ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM); const styles = useThemeStyles(); const {isOffline} = useNetwork(); const {translate} = useLocalize(); @@ -332,9 +323,4 @@ function BaseLoginForm({account, login, onLoginChanged, closeAccount, blurOnSubm BaseLoginForm.displayName = 'BaseLoginForm'; -export default withToggleVisibilityView( - withOnyx({ - account: {key: ONYXKEYS.ACCOUNT}, - closeAccount: {key: ONYXKEYS.FORMS.CLOSE_ACCOUNT_FORM}, - })(forwardRef(BaseLoginForm)), -); +export default withToggleVisibilityView(forwardRef(BaseLoginForm)); From 5ea6a71238ced609647682eb2433b71972edabed Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 15 Oct 2024 14:13:55 +0800 Subject: [PATCH 3/3] fix type --- src/pages/signin/LoginForm/index.native.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/signin/LoginForm/index.native.tsx b/src/pages/signin/LoginForm/index.native.tsx index 6d8f771810e7..9a9730639b21 100644 --- a/src/pages/signin/LoginForm/index.native.tsx +++ b/src/pages/signin/LoginForm/index.native.tsx @@ -6,7 +6,7 @@ import type {InputHandle} from './types'; import type LoginFormProps from './types'; function LoginForm({scrollPageToTop, ...rest}: LoginFormProps, ref: ForwardedRef) { - const loginFormRef = useRef(); + const loginFormRef = useRef(null); useImperativeHandle(ref, () => ({ isInputFocused: loginFormRef.current ? loginFormRef.current.isInputFocused : () => false,