95 lines
3.3 KiB
TypeScript
95 lines
3.3 KiB
TypeScript
// Metro module 16713 (f16714).
|
|
import { useRef, useState, useCallback, useEffect } from "react";
|
|
import { useSafetyFlowTask } from "../../SafetyFlowsTaskContext";
|
|
import { useOnTaskComplete } from "../SafetyFlowsUtils";
|
|
import { TaskInputType } from "../../types";
|
|
import ToastActionCreators from "../../../toast/native/ToastActionCreators";
|
|
import { intl } from "../../../../intl/index.native";
|
|
import SafetyFlows_messages from "../../SafetyFlows.messages";
|
|
import SafetyFlowTaskScreen from "../SafetyFlowTaskScreen";
|
|
import { Stack } from "../../../../design/components/Stack/native/Stack.native";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import { TextInput } from "../../../../design/components/TextInput/native/TextInput.native";
|
|
import ResendVerificationCodeButton from "./ResendVerificationCodeButton";
|
|
export default () => {
|
|
const task = useSafetyFlowTask().task;
|
|
const onTaskComplete = useOnTaskComplete();
|
|
const ref = useRef("");
|
|
const [state, onChange] = useState("");
|
|
const [submitting, setState] = useState(false);
|
|
const [state2, setState2] = useState(false);
|
|
const callback = useCallback(async () => {
|
|
let c28502_3 = 0;
|
|
L14: {
|
|
L13: {
|
|
try {
|
|
const current = ref.current;
|
|
if (current == null) {
|
|
break L14;
|
|
}
|
|
if (current !== "") {
|
|
c28502_3 = 1;
|
|
setState(true);
|
|
setState2(true);
|
|
await onTaskComplete({
|
|
verification_code: current,
|
|
type: TaskInputType.VerificationCode
|
|
});
|
|
(0, setState)(false);
|
|
c28502_3 = 0;
|
|
break L13;
|
|
}
|
|
break L14;
|
|
} catch ($e) {
|
|
let r7 = $e;
|
|
if (c28502_3 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c28502_3 = 0;
|
|
(0, setState)(false);
|
|
(0, setState2)(false);
|
|
ToastActionCreators.open({
|
|
key: "SAFETY_FLOWS_VERIFY_EMAIL_ERROR",
|
|
content: intl.string(SafetyFlows_messages.PfbG6H)
|
|
});
|
|
break L13;
|
|
} catch ($e) {
|
|
r7 = $e;
|
|
if (c28502_3 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
}, [onTaskComplete]);
|
|
useEffect(() => {
|
|
ref.current = state;
|
|
}, [state]);
|
|
useEffect(() => {
|
|
if (!(state.length !== 6 || state2)) {
|
|
callback();
|
|
}
|
|
}, [state, state2, callback]);
|
|
const props = {
|
|
title: intl.string(SafetyFlows_messages["Qm6K/s"]),
|
|
action: intl.string(SafetyFlows_messages.wq2RDq),
|
|
onAction: callback,
|
|
submitting,
|
|
children: null
|
|
};
|
|
const r95 = [<Text variant="text-sm/medium" color="text-subtle">
|
|
{intl.string(SafetyFlows_messages.aveKoG)}
|
|
</Text>, <Stack spacing={Module712.space.PX_8}>
|
|
<TextInput placeholder={intl.string(SafetyFlows_messages.d9Ykjr)} maxLength={6} returnKeyType="done" value={state} onChange={onChange} />
|
|
<ResendVerificationCodeButton setLoading={setState} flowId={task.flow_context?.flow_id} />
|
|
</Stack>];
|
|
props.children = <Stack spacing={Module712.space.PX_16}>{r95}</Stack>;
|
|
return <SafetyFlowTaskScreen {...props} />;
|
|
};
|