219 lines
8.0 KiB
TypeScript
219 lines
8.0 KiB
TypeScript
// Metro module 16127 (f16128).
|
|
import { useState, useRef, useEffect } from "react";
|
|
import { View } from "react-native";
|
|
import UserRequiredActionStore from "../../../../stores/UserRequiredActionStore";
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import { AgeGateAnalyticAction, AgeGateSource } from "../../AgeGateConstants";
|
|
import { ExistingUserAgeGateScreens } from "../ExistingUserAgeGateConstants";
|
|
import { AnalyticEvents, HelpdeskArticles } from "../../../../Constants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import { useNavigation } from "../../../../design/components/Navigator/native/useNavigation.native";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import AnalyticsUtils from "../../../../utils/AnalyticsUtils";
|
|
import { intl, t } from "../../../../intl/index.native";
|
|
import HelpdeskUtils from "../../../../utils/HelpdeskUtils";
|
|
import Module38 from "../../../../_bundle/Module38";
|
|
import { submitDateOfBirth } from "../../AgeGateActionCreators";
|
|
import ModalActionCreators from "../../../../actions/ModalActionCreators";
|
|
import Module3771 from "../../../../_bundle/Module3771";
|
|
import isDateValidDateOfBirth from "../../../auth/native/experiment/isDateValidDateOfBirth";
|
|
import { SafeAreaPaddingView } from "../../../../components_native/common/SafeAreaView";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import DateInput from "./DateInput";
|
|
import { Button } from "../../../../design/components/Button/native/Button.native";
|
|
const useStyles = createStyles({
|
|
container: {
|
|
flex: 1,
|
|
padding: 16,
|
|
alignItems: "center",
|
|
justifyContent: "center"
|
|
},
|
|
header: {
|
|
marginBottom: 8,
|
|
textAlign: "center"
|
|
},
|
|
body: {
|
|
textAlign: "center",
|
|
lineHeight: 20,
|
|
marginBottom: 16
|
|
},
|
|
inputGroup: {
|
|
marginBottom: 16,
|
|
width: "100%"
|
|
},
|
|
buttonWrapper: {
|
|
width: "100%"
|
|
}
|
|
});
|
|
export default function ExistingUserAgeGate(props) {
|
|
let r4, state2, r91, loading, onChangeDate, ref;
|
|
let navigation, stateFromStores, c22808_5, state, setState, setState2, stateFromStores2, _submitBirthday2, _submitBirthdayWithAgeConfirmation2;
|
|
const { onSuccess, onClose, source } = props;
|
|
navigation = void 0;
|
|
stateFromStores = void 0;
|
|
c22808_5 = void 0;
|
|
state = void 0;
|
|
setState = void 0;
|
|
setState2 = void 0;
|
|
stateFromStores2 = void 0;
|
|
const submitBirthday2 = function submitBirthday(a0) {
|
|
return _submitBirthday2.apply(this, arguments);
|
|
};
|
|
_submitBirthday2 = function _submitBirthday() {
|
|
const r9 = async (c30955_0) => {
|
|
let r71;
|
|
let c30955_3;
|
|
let c30955_4 = 0;
|
|
let c31788_0, c31788_1;
|
|
L10: {
|
|
try {
|
|
c31788_0 = void 0;
|
|
Module38(c30955_0 != null, "Cannot submit null birthday.");
|
|
c31788_0 = false;
|
|
c30955_4 = 1;
|
|
setState(null);
|
|
setState2(true);
|
|
await submitDateOfBirth(c30955_0, source);
|
|
c30955_4 = 0;
|
|
r71 = {
|
|
shouldShowError: c31788_0
|
|
};
|
|
} catch ($e) {
|
|
const r31 = $e;
|
|
let r7 = r31;
|
|
c30955_3 = r31;
|
|
if (c30955_4 !== 0) {
|
|
while (true) {
|
|
try {
|
|
const r79 = c30955_3;
|
|
c30955_4 = 0;
|
|
c31788_1 = r79;
|
|
if (c31788_1.body != null && c31788_1.body.date_of_birth != null) {
|
|
navigation.push(ExistingUserAgeGateScreens.Blocked, {
|
|
onClose: ModalActionCreators.pop,
|
|
underageMessage: c31788_1.body.date_of_birth,
|
|
existingUser: true
|
|
});
|
|
} else {
|
|
const r86 = c31788_1;
|
|
setState((r86 == null ? void 0 : r86.body?.username) != null ? intl.string(t["TGg/2k"]) : c31788_1.message);
|
|
(0, setState2)(false);
|
|
c31788_0 = true;
|
|
}
|
|
AnalyticsUtils.track(AnalyticEvents.AGE_GATE_ACTION, {
|
|
source,
|
|
action: AgeGateAnalyticAction.AGE_GATE_FAILURE
|
|
});
|
|
r71 = {
|
|
shouldShowError: c31788_0
|
|
};
|
|
break L10;
|
|
} catch (r76) {
|
|
r7 = r76;
|
|
c30955_3 = r76;
|
|
if (c30955_4 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r7;
|
|
}
|
|
}
|
|
return r71;
|
|
};
|
|
_submitBirthday2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
_submitBirthdayWithAgeConfirmation2 = function _submitBirthdayWithAgeConfirmation() {
|
|
const r9 = async () => {
|
|
L12: {
|
|
Module38(state != null, "Cannot submit null birthday.");
|
|
const age = Module3771().diff(state, "years");
|
|
if (age < 18) {
|
|
navigation.push(ExistingUserAgeGateScreens.AgeGateConfirm, {
|
|
source,
|
|
onConfirm: () => submitBirthday2(state),
|
|
age
|
|
});
|
|
break L12;
|
|
}
|
|
await submitBirthday2(state);
|
|
return void 0;
|
|
}
|
|
};
|
|
_submitBirthdayWithAgeConfirmation2 = r9;
|
|
return r9.apply(this, arguments);
|
|
};
|
|
const styles = useStyles();
|
|
navigation = useNavigation();
|
|
stateFromStores = useStateFromStores([UserStore], () => UserStore.getCurrentUser());
|
|
const { NSFW_CHANNEL, NSFW_VOICE_CHANNEL, FAMILY_CENTER } = AgeGateSource;
|
|
const r2 = source === AgeGateSource.NSFW_SERVER || source === AgeGateSource.NSFW_SERVER_INVITE || source === AgeGateSource.NSFW_SERVER_INVITE_EMBED;
|
|
L12: {
|
|
r4 = source === FAMILY_CENTER;
|
|
c22808_5 = r2;
|
|
[state, onChangeDate] = useState(null);
|
|
let state2;
|
|
[state2, setState] = useState(null);
|
|
[loading, setState2] = useState(false);
|
|
ref = useRef(null);
|
|
stateFromStores2 = useStateFromStores([UserRequiredActionStore], () => UserRequiredActionStore.getAction());
|
|
useEffect(() => {
|
|
if (stateFromStores2 != null && onClose != null) {
|
|
onClose();
|
|
}
|
|
}, [stateFromStores2, onClose]);
|
|
useEffect(() => {
|
|
if (stateFromStores?.nsfwAllowed === false && c22808_5) {
|
|
navigation.push(ExistingUserAgeGateScreens.Pawtect);
|
|
} else if (stateFromStores?.nsfwAllowed != null) {
|
|
onSuccess();
|
|
}
|
|
}, [stateFromStores, onSuccess, r2, navigation]);
|
|
useEffect(() => {
|
|
AnalyticsUtils.track(AnalyticEvents.AGE_GATE_ACTION, {
|
|
source,
|
|
action: AgeGateAnalyticAction.AGE_GATE_OPEN
|
|
});
|
|
}, [source]);
|
|
if (source !== NSFW_CHANNEL && (source !== NSFW_VOICE_CHANNEL && !r2)) {
|
|
if (r4) {
|
|
r91 = intl.string(t.mhUrKS);
|
|
break L12;
|
|
}
|
|
r91 = intl.format(t.EcJBEI, {
|
|
helpURL: HelpdeskUtils.getArticleURL(HelpdeskArticles.AGE_GATE)
|
|
});
|
|
} else {
|
|
r91 = intl.format(t.n3QjDE, {
|
|
helpURL: HelpdeskUtils.getArticleURL(HelpdeskArticles.AGE_GATE)
|
|
});
|
|
}
|
|
}
|
|
const r121 = r2 ? intl.string(t["H0SG/g"]) : r4 ? intl.string(t.M7mt7m) : intl.string(t.F8otRo);
|
|
const isDateValidDateOfBirth2 = isDateValidDateOfBirth(state);
|
|
const r128 = !isDateValidDateOfBirth2;
|
|
const error = isDateValidDateOfBirth2 ? state2 : state != null ? intl.string(t.udnqh6) : state2;
|
|
const r151 = [<Text style={styles.header} variant="heading-xl/extrabold" color="mobile-text-heading-primary">{r121}</Text>, <Text style={styles.body} variant="text-md/medium" color="interactive-text-default">{r91}</Text>, <DateInput style={styles.inputGroup} ref={ref} label={intl.string(t.xNpFJ6)} date={state} onChangeDate={onChangeDate} error={error} />, ,];
|
|
const props2 = {
|
|
loading,
|
|
disabled: null,
|
|
text: null,
|
|
onPress: null,
|
|
grow: true
|
|
};
|
|
if (!loading) {
|
|
loading = r128;
|
|
}
|
|
props2.disabled = loading;
|
|
props2.text = intl.string(t.PDTjLN);
|
|
props2.onPress = function submitBirthdayWithAgeConfirmation() {
|
|
return _submitBirthdayWithAgeConfirmation2.apply(this, arguments);
|
|
};
|
|
r151[3] = <View style={styles.buttonWrapper}>
|
|
<Button {...props2} />
|
|
</View>;
|
|
return <SafeAreaPaddingView top style={styles.container}>{r151}</SafeAreaPaddingView>;
|
|
};
|