256 lines
10 KiB
TypeScript
256 lines
10 KiB
TypeScript
// Metro module 6771 (f6772).
|
|
import _slicedToArray from "../../../_bundle/_slicedToArray";
|
|
import { useState, useEffect, useMemo, useRef, useCallback } from "react";
|
|
import { ActivityIndicator } from "react-native";
|
|
import { HelpdeskArticles } from "../../../Constants";
|
|
import { jsx } from "react/jsx-runtime";
|
|
import { AgeAssuranceMethod } from "../../../_bundle/Module1892";
|
|
import { WalletIcon } from "../../../design/components/Icon/native/redesign/generated/WalletIcon";
|
|
import { UserCircleIcon } from "../../../design/components/Icon/native/redesign/generated/UserCircleIcon";
|
|
import { IdIcon } from "../../../design/components/Icon/native/redesign/generated/IdIcon";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { useIsSuspendedUser } from "../../safety_hub/SafetyHubUtils";
|
|
import { useAgeVerificationMethodsV2 } from "../hooks/useAgeVerificationMethodsV2";
|
|
import { checkGoogleWalletAvailable } from "../GoogleWalletActionCreators.native";
|
|
import { useInitiateAgeVerification, getAgeVerificationGetStartedTitle, getAgeVerificationGetStartedSubtitle } from "../AgeVerificationUtils";
|
|
import { V2_METHOD_TO_VERIFICATION_METHOD, V2_VENDOR_TO_VERIFICATION_VENDOR } from "../AgeVerificationMethodsV2";
|
|
import { ModalScreen } from "../../../design/components/Modal/native/ModalScreen.native";
|
|
import { ModalContent } from "../../../design/components/Modal/native/ModalContent.native";
|
|
import { Stack } from "../../../design/components/Stack/native/Stack.native";
|
|
import { AgeVerificationSpotIllustration } from "../../../design/assets/native";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import AgeVerificationActionCreators_native from "../AgeVerificationActionCreators.native";
|
|
import HelpdeskUtils from "../../../utils/HelpdeskUtils";
|
|
import { HelpMessage, HelpMessageTypes } from "../../../design/void/native";
|
|
import { Button } from "../../../design/components/Button/native/Button.native";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import AgeAssurance_messages from "../AgeAssurance.messages";
|
|
import { TableRowGroup } from "../../../design/components/TableRow/native/TableRowGroup.native";
|
|
import { TableRow } from "../../../design/components/TableRow/native/TableRow.native";
|
|
import ModalActionCreators from "../../../actions/ModalActionCreators";
|
|
import { getHeaderCloseButton, getHeaderBackButton } from "../../../design/components/Navigator/native/NavigatorHeader.native";
|
|
import GoogleWalletVerificationScreen from "./GoogleWalletVerificationScreen";
|
|
import { v4 } from "../../../_bundle/Module514";
|
|
import { Navigator } from "../../../design/components/Navigator/native/Navigator.native";
|
|
let MethodErrorScreen, c4353_10, useStyles, c4353_12;
|
|
let env4353 = {};
|
|
const MethodsScreen = function MethodsScreen(props) {
|
|
let c15906_0;
|
|
let env15905 = {
|
|
$parent: env4353
|
|
};
|
|
const { entryPoint: entryPoint3, navigation } = props;
|
|
env15905[0] = navigation;
|
|
const onClose3 = props.onClose;
|
|
env15905[1] = void 0;
|
|
env15905[2] = void 0;
|
|
env15905[3] = void 0;
|
|
env15905[4] = void 0;
|
|
env15905[5] = void 0;
|
|
env15905[6] = void 0;
|
|
const styles = useStyles();
|
|
const isSuspendedUser = useIsSuspendedUser();
|
|
const ageVerificationMethodsV2 = useAgeVerificationMethodsV2();
|
|
const { loading, error, methods } = ageVerificationMethodsV2;
|
|
env15905[1] = methods;
|
|
const refetch = ageVerificationMethodsV2.refetch;
|
|
const r42 = _slicedToArray(useState(false), 2);
|
|
const r43 = r42[0];
|
|
env15905[2] = r43;
|
|
env15905[3] = r42[1];
|
|
useEffect(() => {
|
|
let c25998_0 = false;
|
|
checkGoogleWalletAvailable().then((result) => {
|
|
if (!c25998_0) {
|
|
(0, env15905[3])(result);
|
|
}
|
|
});
|
|
return () => {
|
|
c25998_0 = true;
|
|
};
|
|
}, []);
|
|
const memo3 = useMemo(() => env15905[1].filter((item) => item.method !== AgeAssuranceMethod.GOOGLE_WALLET || env15905[2]), [methods, r43]);
|
|
const r3 = memo3.length > 0;
|
|
const initiateAgeVerification = useInitiateAgeVerification({
|
|
onComplete: onClose3,
|
|
entryPoint: entryPoint3,
|
|
shouldShowExpressiveModal: true
|
|
}).initiateAgeVerification;
|
|
env15905[4] = initiateAgeVerification;
|
|
env15905[5] = useRef(false);
|
|
c15906_0 = void 0;
|
|
c15906_0 = async (c29840_0) => {
|
|
let c29840_3;
|
|
let c29840_4 = 0;
|
|
L18: {
|
|
L17: {
|
|
try {
|
|
if (env15905[5].current) {
|
|
break L18;
|
|
}
|
|
if (c29840_0.method !== AgeAssuranceMethod.GOOGLE_WALLET) {
|
|
const r43 = V2_METHOD_TO_VERIFICATION_METHOD[c29840_0.method];
|
|
const r48 = V2_VENDOR_TO_VERIFICATION_VENDOR[c29840_0.vendor];
|
|
if (r43 != null && r48 != null) {
|
|
env15905[5].current = true;
|
|
c29840_4 = 1;
|
|
await (0, env15905[4])(r43, r48);
|
|
c29840_4 = 0;
|
|
env15905[5].current = false;
|
|
break L17;
|
|
}
|
|
env15905[0].navigate(c4353_12.METHOD_ERROR);
|
|
break L18;
|
|
}
|
|
env15905[0].navigate(c4353_12.GOOGLE_WALLET_VERIFICATION);
|
|
break L18;
|
|
} catch ($e) {
|
|
const r30 = $e;
|
|
let r7 = r30;
|
|
c29840_3 = r30;
|
|
if (c29840_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r90 = c29840_3;
|
|
c29840_4 = 0;
|
|
env15905[5].current = false;
|
|
throw r90;
|
|
} catch (r87) {
|
|
r7 = r87;
|
|
c29840_3 = r87;
|
|
if (c29840_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
};
|
|
env15905[6] = useCallback(function() {
|
|
return c15906_0.apply(this, arguments);
|
|
}, [navigation, initiateAgeVerification]);
|
|
const r109 = [<Stack align="center" justify="center" spacing={16}>
|
|
<AgeVerificationSpotIllustration width={150} height={100} />
|
|
<Stack align="center" justify="center" spacing={8}>
|
|
<Text accessibilityRole="header" variant="heading-xl/bold" color="mobile-text-heading-primary">
|
|
{getAgeVerificationGetStartedTitle(entryPoint3)}
|
|
</Text>
|
|
<Text variant="text-md/medium" color="text-strong" style={styles.header}>
|
|
{getAgeVerificationGetStartedSubtitle(entryPoint3, () => {
|
|
AgeVerificationActionCreators_native.openUrl(HelpdeskUtils.getArticleURL(HelpdeskArticles.TIGGER_PAWTECT_LEARN_MORE));
|
|
}, isSuspendedUser)}
|
|
</Text>
|
|
</Stack>
|
|
</Stack>, loading && <Stack align="center" justify="center" style={styles.loadingContainer}>
|
|
<ActivityIndicator size="large" />
|
|
</Stack>, (loading ? !loading : !r3) && <Stack style={styles.emptyContainer}>
|
|
<HelpMessage messageType={HelpMessageTypes.ERROR} button={<Button variant="primary" size="sm" text={intl.string(AgeAssurance_messages.hDvmYP)} onPress={refetch} />}>
|
|
{intl.string(error ? AgeAssurance_messages.Bkmk4Y : AgeAssurance_messages.cR6336)}
|
|
</HelpMessage>
|
|
</Stack>, (loading ? !loading : r3) && <TableRowGroup hasIcons>
|
|
{memo3.map((item) => {
|
|
const IconComponent = c4353_10[item.method];
|
|
return <TableRow key={`${item.method}-${item.vendor}`} arrow icon={IconComponent != null ? <TableRow.Icon IconComponent={IconComponent} variant="secondary" /> : void 0} label={item.title} subLabel={<Stack direction="vertical" spacing={4}>
|
|
<Text variant="text-sm/normal" color="text-muted">{item.description}</Text>
|
|
{item.providedBy != null && <Text variant="text-sm/normal" color="text-subtle">{item.providedBy}</Text>}
|
|
</Stack>} onPress={() => {
|
|
(0, env15905[6])(item);
|
|
}} />;
|
|
})}
|
|
</TableRowGroup>];
|
|
return <ModalScreen>
|
|
<ModalContent>
|
|
<Stack align="stretch" spacing={24} style={styles.container}>{r109}</Stack>
|
|
</ModalContent>
|
|
</ModalScreen>;
|
|
};
|
|
MethodErrorScreen = function MethodErrorScreen() {
|
|
return <ModalScreen>
|
|
<ModalContent>
|
|
<Stack style={useStyles().errorMessage}>
|
|
<HelpMessage messageType={HelpMessageTypes.ERROR}>
|
|
{intl.string(AgeAssurance_messages["1RD2jW"])}
|
|
</HelpMessage>
|
|
</Stack>
|
|
</ModalContent>
|
|
</ModalScreen>;
|
|
};
|
|
const r32 = {};
|
|
r32[AgeAssuranceMethod.GOOGLE_WALLET] = WalletIcon;
|
|
r32[AgeAssuranceMethod.FACIAL_AGE_ESTIMATION] = UserCircleIcon;
|
|
r32[AgeAssuranceMethod.ID_SELFIE_MATCH] = IdIcon;
|
|
c4353_10 = r32;
|
|
useStyles = createStyles({
|
|
headerStyle: {
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWER,
|
|
shadowColor: "transparent"
|
|
},
|
|
container: {
|
|
alignSelf: "stretch"
|
|
},
|
|
header: {
|
|
textAlign: "center"
|
|
},
|
|
loadingContainer: {
|
|
marginTop: Module712.space.PX_24
|
|
},
|
|
emptyContainer: {
|
|
marginTop: Module712.space.PX_24
|
|
},
|
|
errorMessage: {
|
|
marginTop: Module712.space.PX_24
|
|
}
|
|
});
|
|
c4353_12 = {
|
|
METHODS: "METHODS",
|
|
GOOGLE_WALLET_VERIFICATION: "GOOGLE_WALLET_VERIFICATION",
|
|
METHOD_ERROR: "METHOD_ERROR"
|
|
};
|
|
export default function AgeVerificationExpressiveV2Modal(props) {
|
|
const { entryPoint, onClose } = props;
|
|
const styles = useStyles();
|
|
let c15907_2 = styles;
|
|
const memo = useMemo(() => v4(), []);
|
|
return <Navigator screens={useMemo(() => {
|
|
const memo2 = memo;
|
|
const entryPoint2 = entryPoint;
|
|
const onClose2 = onClose;
|
|
const closeModal2 = function closeModal() {
|
|
ModalActionCreators.pop();
|
|
onClose2();
|
|
};
|
|
const r14 = {};
|
|
r14[c4353_12.METHODS] = {
|
|
headerStyle: c15907_2.headerStyle,
|
|
headerTitle: () => null,
|
|
headerLeft: getHeaderCloseButton(closeModal2),
|
|
render: (a0, a1) => (0, jsx)(MethodsScreen, {
|
|
entryPoint: entryPoint2,
|
|
navigation: a1,
|
|
onClose: closeModal2
|
|
})
|
|
};
|
|
r14[c4353_12.GOOGLE_WALLET_VERIFICATION] = {
|
|
headerStyle: c15907_2.headerStyle,
|
|
headerTitle: () => null,
|
|
headerLeft: getHeaderBackButton(),
|
|
render: () => (0, jsx)(GoogleWalletVerificationScreen, {
|
|
onClose: closeModal2,
|
|
modalSessionId: memo2
|
|
})
|
|
};
|
|
r14[c4353_12.METHOD_ERROR] = {
|
|
headerStyle: c15907_2.headerStyle,
|
|
headerTitle: () => null,
|
|
headerLeft: getHeaderBackButton(),
|
|
render: () => (0, jsx)(MethodErrorScreen, {})
|
|
};
|
|
return r14;
|
|
}, [styles, memo, entryPoint, onClose])} initialRouteName={c4353_12.METHODS} headerBackTitle={intl.string(t["13/7kX"])} />;
|
|
};
|