106 lines
4.4 KiB
TypeScript
106 lines
4.4 KiB
TypeScript
// Metro module 9224 (f9225).
|
|
import { useState, useCallback } from "react";
|
|
import { ScrollView, View } from "react-native";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import { ChangeEmailFields, useChangeEmailError, useChangeEmailStore } from "../../ChangeEmailStore";
|
|
import { AnalyticEvents } from "../../../../Constants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { useNavigation } from "../../../../design/components/Navigator/native/useNavigation.native";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import { VerificationModalScenes } from "../../../../ConstantsIOS";
|
|
import { saveEmail, finishChangeEmailFlow, finishVerifyEmailFlow } from "../ChangeEmailUtils";
|
|
import AnalyticsUtils from "../../../../utils/AnalyticsUtils";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import FreeFormInputGroup from "../../../../design/void/Form/native/FreeFormInputGroup";
|
|
import { Button } from "../../../../design/components/Button/native/Button.native";
|
|
const useStyles = createStyles({
|
|
background: {
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
|
|
},
|
|
container: {
|
|
paddingVertical: 12,
|
|
paddingHorizontal: 16
|
|
},
|
|
title: {
|
|
textAlign: "center"
|
|
},
|
|
prompt: {
|
|
marginTop: 8,
|
|
lineHeight: 18,
|
|
textAlign: "center"
|
|
},
|
|
input: {
|
|
marginTop: 24,
|
|
marginBottom: 16
|
|
}
|
|
});
|
|
export default function EnterEmail(props) {
|
|
let state, c17076_5, emailToken, callback;
|
|
const { isChangeEmail, changeEmailReason } = props;
|
|
state = void 0;
|
|
c17076_5 = void 0;
|
|
emailToken = void 0;
|
|
callback = void 0;
|
|
const styles = useStyles();
|
|
const navigation = useNavigation();
|
|
const stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
|
|
let onChangeText;
|
|
[state, onChangeText] = useState("");
|
|
const [error, r13] = useChangeEmailError(ChangeEmailFields.EMAIL);
|
|
c17076_5 = r13;
|
|
emailToken = useChangeEmailStore().emailToken;
|
|
callback = useCallback((c26394_0) => navigation.getState().routes.findIndex((route) => route.name === c26394_0), [navigation]);
|
|
const callback2 = useCallback(() => {
|
|
const VERIFY_PASSWORD = VerificationModalScenes.VERIFY_PASSWORD;
|
|
let c26395_0 = async (password) => {
|
|
let r27;
|
|
L11: {
|
|
const r26 = stateFromStores == null;
|
|
r27 = null;
|
|
if (r26) {
|
|
break L11;
|
|
}
|
|
c17076_5(null);
|
|
return await saveEmail({
|
|
email: state,
|
|
password,
|
|
emailToken
|
|
}, navigation, callback);
|
|
}
|
|
return r27;
|
|
};
|
|
navigation.push(VERIFY_PASSWORD, {
|
|
onSubmit: function() {
|
|
return c26395_0.apply(this, arguments);
|
|
},
|
|
onSuccess: () => {
|
|
if (isChangeEmail) {
|
|
AnalyticsUtils.track(AnalyticEvents.USER_ACCOUNT_EMAIL_CHANGE_SAVE_NEW_EMAIL, {
|
|
change_email_reason_enum: changeEmailReason
|
|
});
|
|
finishChangeEmailFlow(navigation, state);
|
|
} else {
|
|
finishVerifyEmailFlow(navigation, callback);
|
|
}
|
|
},
|
|
hideUnverifiedBanner: true
|
|
});
|
|
}, [navigation, stateFromStores, r13, state, emailToken, callback, isChangeEmail, changeEmailReason]);
|
|
return stateFromStores == null ? null : <ScrollView style={styles.background} keyboardShouldPersistTaps="handled" alwaysBounceVertical={false}>
|
|
<View style={styles.container}>
|
|
<Text style={styles.title} accessibilityRole="header" variant="heading-xl/extrabold" color="mobile-text-heading-primary">
|
|
{stateFromStores.email != null ? intl.string(t.Vm8akB) : intl.string(t["CDTD/K"])}
|
|
</Text>
|
|
<Text style={styles.prompt} variant="text-sm/medium" color="text-default">
|
|
{stateFromStores.email != null ? intl.formatToPlainString(t.Z7CaI7, {
|
|
email: stateFromStores.email
|
|
}) : intl.string(t.YXXMxK)}
|
|
</Text>
|
|
<FreeFormInputGroup style={styles.input} label={intl.string(t["w/qqKK"])} textContentType="emailAddress" keyboardType="email-address" value={state} onChangeText={onChangeText} onSubmitEditing={callback2} placeholder={intl.string(t.dI4d4S)} returnKeyType="done" autoCapitalize="none" error={error} autoFocus />
|
|
<Button text={intl.string(t.Vm8akB)} onPress={callback2} disabled={state === "" || state === stateFromStores.email} />
|
|
</View>
|
|
</ScrollView>;
|
|
};
|