Skip to content

Commit 34dd365

Browse files
authored
Merge pull request Expensify#67733 from thelullabyy/update/65967/missing-page
Remove remaining withOnyx HOCs from the project | Batch 6
2 parents 5f9fba5 + a16003a commit 34dd365

1 file changed

Lines changed: 10 additions & 22 deletions

File tree

src/pages/signin/UnlinkLoginForm.tsx

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,28 @@
11
import {Str} from 'expensify-common';
22
import React, {useMemo} from 'react';
33
import {View} from 'react-native';
4-
import {withOnyx} from 'react-native-onyx';
5-
import type {OnyxEntry} from 'react-native-onyx';
64
import Button from '@components/Button';
75
import DotIndicatorMessage from '@components/DotIndicatorMessage';
86
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
97
import Text from '@components/Text';
108
import useLocalize from '@hooks/useLocalize';
119
import useNetwork from '@hooks/useNetwork';
10+
import useOnyx from '@hooks/useOnyx';
1211
import useThemeStyles from '@hooks/useThemeStyles';
13-
import * as ErrorUtils from '@libs/ErrorUtils';
14-
import * as Session from '@userActions/Session';
12+
import {getErrorsWithTranslationData} from '@libs/ErrorUtils';
13+
import {requestUnlinkValidationLink} from '@userActions/Session';
1514
import redirectToSignIn from '@userActions/SignInRedirect';
1615
import CONST from '@src/CONST';
1716
import ONYXKEYS from '@src/ONYXKEYS';
18-
import type {Account, Credentials} from '@src/types/onyx';
1917
import {isEmptyObject} from '@src/types/utils/EmptyObject';
2018

21-
type UnlinkLoginFormOnyxProps = {
22-
/** State for the account */
23-
account: OnyxEntry<Account>;
24-
25-
/** The credentials of the logged in person */
26-
credentials: OnyxEntry<Credentials>;
27-
};
28-
29-
type UnlinkLoginFormProps = UnlinkLoginFormOnyxProps;
30-
31-
function UnlinkLoginForm({account, credentials}: UnlinkLoginFormProps) {
19+
function UnlinkLoginForm() {
3220
const styles = useThemeStyles();
3321
const {translate} = useLocalize();
3422
const {isOffline} = useNetwork();
23+
const [account] = useOnyx(ONYXKEYS.ACCOUNT, {canBeMissing: true});
24+
const [credentials] = useOnyx(ONYXKEYS.CREDENTIALS, {canBeMissing: true});
25+
3526
const unlinkMessage =
3627
account?.message === 'unlinkLoginForm.linkSent' || account?.message === 'unlinkLoginForm.successfullyUnlinkedLogin' ? translate(account?.message) : account?.message;
3728
const primaryLogin = useMemo(() => {
@@ -68,7 +59,7 @@ function UnlinkLoginForm({account, credentials}: UnlinkLoginFormProps) {
6859
<DotIndicatorMessage
6960
style={[styles.mb5]}
7061
type="error"
71-
messages={ErrorUtils.getErrorsWithTranslationData(account.errors)}
62+
messages={getErrorsWithTranslationData(account.errors)}
7263
/>
7364
)}
7465
<View style={[styles.mb4, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter]}>
@@ -82,7 +73,7 @@ function UnlinkLoginForm({account, credentials}: UnlinkLoginFormProps) {
8273
success
8374
text={translate('unlinkLoginForm.unlink')}
8475
isLoading={account?.isLoading && account.loadingForm === CONST.FORMS.UNLINK_LOGIN_FORM}
85-
onPress={() => Session.requestUnlinkValidationLink()}
76+
onPress={() => requestUnlinkValidationLink()}
8677
isDisabled={!!isOffline || !!account?.message}
8778
/>
8879
</View>
@@ -92,7 +83,4 @@ function UnlinkLoginForm({account, credentials}: UnlinkLoginFormProps) {
9283

9384
UnlinkLoginForm.displayName = 'UnlinkLoginForm';
9485

95-
export default withOnyx<UnlinkLoginFormProps, UnlinkLoginFormOnyxProps>({
96-
credentials: {key: ONYXKEYS.CREDENTIALS},
97-
account: {key: ONYXKEYS.ACCOUNT},
98-
})(UnlinkLoginForm);
86+
export default UnlinkLoginForm;

0 commit comments

Comments
 (0)