Skip to content

Commit 88713ab

Browse files
authored
Merge pull request #52523 from wildan-m/wildan/fix/51189-fix-magic-code-modal-gone-reconnect
Fix ValidateCodeActionModal dismissed when re-connect
2 parents 4964af5 + a0f382b commit 88713ab

File tree

1 file changed

+67
-65
lines changed

1 file changed

+67
-65
lines changed

src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Navigation from '@libs/Navigation/Navigation';
2121
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
2222
import {addSMSDomainIfPhoneNumber} from '@libs/PhoneNumber';
2323
import * as UserUtils from '@libs/UserUtils';
24-
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
24+
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
2525
import * as User from '@userActions/User';
2626
import CONST from '@src/CONST';
2727
import ONYXKEYS from '@src/ONYXKEYS';
@@ -109,72 +109,74 @@ function NewContactMethodPage({route}: NewContactMethodPageProps) {
109109
Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.getRoute(navigateBackTo));
110110
}, [navigateBackTo]);
111111

112+
if (isActingAsDelegate) {
113+
return <NotFoundPage onBackButtonPress={onBackButtonPress} />;
114+
}
115+
112116
return (
113-
<AccessOrNotFoundWrapper shouldBeBlocked={isActingAsDelegate}>
114-
<ScreenWrapper
115-
onEntryTransitionEnd={() => loginInputRef.current?.focus()}
116-
includeSafeAreaPaddingBottom={false}
117-
shouldEnableMaxHeight
118-
testID={NewContactMethodPage.displayName}
117+
<ScreenWrapper
118+
onEntryTransitionEnd={() => loginInputRef.current?.focus()}
119+
includeSafeAreaPaddingBottom={false}
120+
shouldEnableMaxHeight
121+
testID={NewContactMethodPage.displayName}
122+
>
123+
<HeaderWithBackButton
124+
title={translate('contacts.newContactMethod')}
125+
onBackButtonPress={onBackButtonPress}
126+
/>
127+
<FormProvider
128+
formID={ONYXKEYS.FORMS.NEW_CONTACT_METHOD_FORM}
129+
validate={validate}
130+
onSubmit={handleValidateMagicCode}
131+
submitButtonText={translate('common.add')}
132+
style={[styles.flexGrow1, styles.mh5]}
119133
>
120-
<HeaderWithBackButton
121-
title={translate('contacts.newContactMethod')}
122-
onBackButtonPress={onBackButtonPress}
123-
/>
124-
<FormProvider
125-
formID={ONYXKEYS.FORMS.NEW_CONTACT_METHOD_FORM}
126-
validate={validate}
127-
onSubmit={handleValidateMagicCode}
128-
submitButtonText={translate('common.add')}
129-
style={[styles.flexGrow1, styles.mh5]}
130-
>
131-
<Text style={styles.mb5}>{translate('common.pleaseEnterEmailOrPhoneNumber')}</Text>
132-
<View style={styles.mb6}>
133-
<InputWrapper
134-
InputComponent={TextInput}
135-
label={`${translate('common.email')}/${translate('common.phoneNumber')}`}
136-
aria-label={`${translate('common.email')}/${translate('common.phoneNumber')}`}
137-
role={CONST.ROLE.PRESENTATION}
138-
inputMode={CONST.INPUT_MODE.EMAIL}
139-
ref={loginInputRef}
140-
inputID={INPUT_IDS.PHONE_OR_EMAIL}
141-
autoCapitalize="none"
142-
enterKeyHint="done"
143-
maxLength={CONST.LOGIN_CHARACTER_LIMIT}
144-
/>
145-
</View>
146-
{hasFailedToSendVerificationCode && (
147-
<DotIndicatorMessage
148-
messages={ErrorUtils.getLatestErrorField(pendingContactAction, 'actionVerified')}
149-
type="error"
150-
/>
151-
)}
152-
</FormProvider>
153-
<ValidateCodeActionModal
154-
validatePendingAction={pendingContactAction?.pendingFields?.actionVerified}
155-
validateError={validateLoginError}
156-
handleSubmitForm={addNewContactMethod}
157-
clearError={() => {
158-
if (!loginData) {
159-
return;
160-
}
161-
User.clearContactMethodErrors(addSMSDomainIfPhoneNumber(pendingContactAction?.contactMethod ?? contactMethod), 'addedLogin');
162-
}}
163-
onClose={() => {
164-
if (loginData?.errorFields && pendingContactAction?.contactMethod) {
165-
User.clearContactMethod(pendingContactAction?.contactMethod);
166-
User.clearUnvalidatedNewContactMethodAction();
167-
}
168-
setIsValidateCodeActionModalVisible(false);
169-
}}
170-
isVisible={isValidateCodeActionModalVisible}
171-
hasMagicCodeBeenSent={!!loginData?.validateCodeSent}
172-
title={translate('delegate.makeSureItIsYou')}
173-
sendValidateCode={() => User.requestValidateCodeAction()}
174-
descriptionPrimary={translate('contacts.enterMagicCode', {contactMethod})}
175-
/>
176-
</ScreenWrapper>
177-
</AccessOrNotFoundWrapper>
134+
<Text style={styles.mb5}>{translate('common.pleaseEnterEmailOrPhoneNumber')}</Text>
135+
<View style={styles.mb6}>
136+
<InputWrapper
137+
InputComponent={TextInput}
138+
label={`${translate('common.email')}/${translate('common.phoneNumber')}`}
139+
aria-label={`${translate('common.email')}/${translate('common.phoneNumber')}`}
140+
role={CONST.ROLE.PRESENTATION}
141+
inputMode={CONST.INPUT_MODE.EMAIL}
142+
ref={loginInputRef}
143+
inputID={INPUT_IDS.PHONE_OR_EMAIL}
144+
autoCapitalize="none"
145+
enterKeyHint="done"
146+
maxLength={CONST.LOGIN_CHARACTER_LIMIT}
147+
/>
148+
</View>
149+
{hasFailedToSendVerificationCode && (
150+
<DotIndicatorMessage
151+
messages={ErrorUtils.getLatestErrorField(pendingContactAction, 'actionVerified')}
152+
type="error"
153+
/>
154+
)}
155+
</FormProvider>
156+
<ValidateCodeActionModal
157+
validatePendingAction={pendingContactAction?.pendingFields?.actionVerified}
158+
validateError={validateLoginError}
159+
handleSubmitForm={addNewContactMethod}
160+
clearError={() => {
161+
if (!loginData) {
162+
return;
163+
}
164+
User.clearContactMethodErrors(addSMSDomainIfPhoneNumber(pendingContactAction?.contactMethod ?? contactMethod), 'addedLogin');
165+
}}
166+
onClose={() => {
167+
if (loginData?.errorFields && pendingContactAction?.contactMethod) {
168+
User.clearContactMethod(pendingContactAction?.contactMethod);
169+
User.clearUnvalidatedNewContactMethodAction();
170+
}
171+
setIsValidateCodeActionModalVisible(false);
172+
}}
173+
isVisible={isValidateCodeActionModalVisible}
174+
hasMagicCodeBeenSent={!!loginData?.validateCodeSent}
175+
title={translate('delegate.makeSureItIsYou')}
176+
sendValidateCode={() => User.requestValidateCodeAction()}
177+
descriptionPrimary={translate('contacts.enterMagicCode', {contactMethod})}
178+
/>
179+
</ScreenWrapper>
178180
);
179181
}
180182

0 commit comments

Comments
 (0)