75 lines
2.7 KiB
TypeScript
75 lines
2.7 KiB
TypeScript
// Metro module 16709 (f16710).
|
|
import { useCallback } from "react";
|
|
import UserStore from "../../../stores/UserStore";
|
|
import { TASK_TYPE_TO_SCREENS, TaskType, SafetyFlowScreens } from "../types";
|
|
import { getCurrentTask, completeTask } from "../SafetyFlowsActionCreators";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import { SAFETY_FLOWS_MODAL_KEY } from "../constants";
|
|
import ToastActionCreators from "../../toast/native/ToastActionCreators";
|
|
import Module10356 from "../../../_bundle/Module10356";
|
|
import { intl } from "../../../intl/index.native";
|
|
import SafetyFlows_messages from "../SafetyFlows.messages";
|
|
import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native";
|
|
import { useSafetyFlowTask } from "../SafetyFlowsTaskContext";
|
|
let navigateToScreenForTask;
|
|
let env12038 = {};
|
|
export async function fetchAndUpdateTask(c28501_0) {
|
|
let c31104_0 = c28501_0;
|
|
let c31104_1 = await getCurrentTask();
|
|
if (c31104_1 != null) {
|
|
(0, c31104_0)(c31104_1);
|
|
}
|
|
return c31104_1;
|
|
}
|
|
navigateToScreenForTask = function navigateToScreenForTask(a0, a1) {
|
|
if (a1 == null) {
|
|
ModalActionCreators.popWithKey(SAFETY_FLOWS_MODAL_KEY);
|
|
ToastActionCreators.open({
|
|
key: "SAFETY_FLOWS_VERIFY_EMAIL_SUCCESS",
|
|
icon: Module10356,
|
|
content: intl.string(SafetyFlows_messages["/fHz9S"])
|
|
});
|
|
return void 0;
|
|
}
|
|
const task_type = a1.task_type;
|
|
const r9 = TASK_TYPE_TO_SCREENS[task_type];
|
|
const r14 = r9 == null ? null : task_type === TaskType.EMAIL_VERIFICATION ? UserStore.getCurrentUser()?.email != null ? [SafetyFlowScreens.VERIFY_EMAIL] : r9 : r9;
|
|
if (r14 != null) {
|
|
a0.push(r14[0]);
|
|
} else {
|
|
a0.push(SafetyFlowScreens.UPDATE_APP);
|
|
}
|
|
};
|
|
export function getScreensForTaskType(a0) {
|
|
const r8 = TASK_TYPE_TO_SCREENS[a0];
|
|
return r8 == null ? null : a0 === TaskType.EMAIL_VERIFICATION ? UserStore.getCurrentUser()?.email != null ? [SafetyFlowScreens.VERIFY_EMAIL] : r8 : r8;
|
|
}
|
|
export { navigateToScreenForTask };
|
|
export function useOnTaskComplete() {
|
|
let env23381 = {
|
|
$parent: env12038
|
|
};
|
|
const navigation = useNavigation();
|
|
env23381[0] = navigation;
|
|
const safetyFlowTask = useSafetyFlowTask();
|
|
const task = safetyFlowTask.task;
|
|
env23381[1] = task;
|
|
const setTask = safetyFlowTask.setTask;
|
|
env23381[2] = setTask;
|
|
let c23382_0 = async (data) => {
|
|
let c31105_2;
|
|
c31105_2 = void 0;
|
|
const r33 = env23381[1];
|
|
await completeTask({
|
|
task_id: r33.task_id,
|
|
flow_id: r33.flow_context.flow_id,
|
|
data
|
|
});
|
|
let c31838_0 = await (0, fetchAndUpdateTask)(env23381[2]);
|
|
(0, navigateToScreenForTask)(env23381[0], c31838_0);
|
|
};
|
|
return useCallback(function() {
|
|
return c23382_0.apply(this, arguments);
|
|
}, [navigation, task, setTask]);
|
|
}
|