Files
discord-decomp/modules/safety_hub/native/AppealIngestionModal.tsx
T
2026-11-01 12:12:55 +02:00

244 lines
11 KiB
TypeScript

// Metro module 11087 (f11088).
import { useState, useEffect, useCallback } from "react";
import { View } from "react-native";
import SafetyHubStore from "../SafetyHubStore";
import { APPEAL_INGESTION_IMPRESSION_PROPERTIES, AppealIngestionSections } from "../SafetyHubConstants";
import { EMPTY_STRING_SNOWFLAKE_ID } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import { Text } from "../../../design/components/Text/native/Text";
import { useStateFromStores } from "../../../_bundle/Module589";
import { useSafetyHubClassification, useSafetyHubAppealSignal } from "../hooks/useSafetyHubClassifications";
import { useNavigation } from "../../../design/components/Navigator/native/useNavigation.native";
import { AppealIngestionType } from "../SafetyHubModels";
import AppealIngestionModalActionCreators from "./AppealIngestionModalActionCreators";
import { requestReview } from "../SafetyHubActionCreators";
import { getRequestReviewErrorFromCode } from "../SafetyHubUtils";
import { SafeAreaPaddingView } from "../../../components_native/common/SafeAreaView";
import { intl, t } from "../../../intl/index.native";
import { Button } from "../../../design/components/Button/native/Button.native";
import { getHeaderCloseButton, getHeaderBackButton } from "../../../design/components/Navigator/native/NavigatorHeader.native";
import AppealIngestionSpeedBump from "./AppealIngestionSpeedBump";
import { ImpressionNames } from "../../../_bundle/Module503";
import AppealIngestionCollectSignal from "./AppealIngestionCollectSignal";
import AppealIngestionConfirmSubmission from "./AppealIngestionConfirmSubmission";
import AppealIngestionRequestSent from "./AppealIngestionRequestSent";
import AppealIngestionThanks from "./AppealIngestionThanks";
import AppealIngestionSpam from "./AppealIngestionSpam";
import useInitialValue from "../../../hooks/useInitialValue";
import { Navigator } from "../../../design/components/Navigator/native/Navigator.native";
const useStyles = createStyles({
container: {
flex: 1,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
},
headerContainer: {
alignSelf: "stretch",
marginTop: 16,
marginBottom: 8,
paddingHorizontal: 16
},
header: {
marginBottom: 8,
textAlign: "center"
},
subheader: {
lineHeight: 20,
marginBottom: 8,
textAlign: "center"
},
separator: {
height: 1,
backgroundColor: Module712.colors.BORDER_SUBTLE,
marginVertical: 24
},
footerContainer: {
marginBottom: 16
},
footerText: {
marginBottom: 16,
textAlign: "center"
},
footerButton: {
paddingHorizontal: 16
}
});
export default function AppealIngestionModal(props) {
const classificationId = props.classificationId;
const safetyHubClassification = useSafetyHubClassification(classificationId);
const isDsaEligible = safetyHubClassification.isDsaEligible;
let c18527_1 = safetyHubClassification.classification?.is_spam || false;
let c18527_2 = safetyHubClassification.classification?.is_coppa || false;
return <Navigator initialRouteName={AppealIngestionSections.SPEED_BUMP} screens={useInitialValue(() => {
const isDsaEligible2 = isDsaEligible;
const isSpam = c18527_1;
const isCoppa = c18527_2;
const r14 = {};
r14[AppealIngestionSections.SPEED_BUMP] = {
headerLeft: getHeaderCloseButton(AppealIngestionModalActionCreators.close),
headerTitle: () => <Text variant="text-md/normal">
{void 0}
</Text>,
render: () => <AppealIngestionSpeedBump isDsaEligible={isDsaEligible2} isSpam={isSpam} isCoppa={isCoppa} />,
impressionName: ImpressionNames.APPEAL_INGESTION_SPEED_BUMP,
impressionProperties: APPEAL_INGESTION_IMPRESSION_PROPERTIES
};
r14[AppealIngestionSections.COLLECT_SIGNAL] = {
headerLeft: getHeaderBackButton(),
headerTitle: () => <Text variant="text-md/normal">
{void 0}
</Text>,
render: () => <AppealIngestionCollectSignal isDsaEligible={isDsaEligible2} />,
impressionName: ImpressionNames.APPEAL_INGESTION_COLLECT_SIGNAL,
impressionProperties: APPEAL_INGESTION_IMPRESSION_PROPERTIES
};
r14[AppealIngestionSections.CONFIRM_SUBMISSION] = {
headerLeft: getHeaderBackButton(),
headerTitle: () => <Text variant="text-md/normal">
{void 0}
</Text>,
render: () => <AppealIngestionConfirmSubmission isDsaEligible={isDsaEligible2} />,
impressionName: ImpressionNames.APPEAL_INGESTION_CONFIRM_SUBMISSION,
impressionProperties: APPEAL_INGESTION_IMPRESSION_PROPERTIES
};
r14[AppealIngestionSections.REQUEST_SENT] = {
headerLeft: getHeaderCloseButton(AppealIngestionModalActionCreators.close),
headerTitle: () => <Text variant="text-md/normal">
{void 0}
</Text>,
render: () => <AppealIngestionRequestSent />,
impressionName: ImpressionNames.APPEAL_INGESTION_REQUEST_SENT,
impressionProperties: APPEAL_INGESTION_IMPRESSION_PROPERTIES
};
r14[AppealIngestionSections.THANKS] = {
headerLeft: getHeaderCloseButton(AppealIngestionModalActionCreators.close),
headerTitle: () => <Text variant="text-md/normal">
{void 0}
</Text>,
render: () => <AppealIngestionThanks />,
impressionName: ImpressionNames.APPEAL_INGESTION_THANKS,
impressionProperties: APPEAL_INGESTION_IMPRESSION_PROPERTIES
};
r14[AppealIngestionSections.SPAM] = {
headerLeft: getHeaderCloseButton(AppealIngestionModalActionCreators.close),
headerTitle: () => <Text variant="text-md/normal">
{void 0}
</Text>,
render: () => <AppealIngestionSpam />,
impressionName: ImpressionNames.APPEAL_INGESTION_SPAM,
impressionProperties: APPEAL_INGESTION_IMPRESSION_PROPERTIES
};
return r14;
})} headerBackTitle={intl.string(t["13/7kX"])} headerTitleAlign="center" />;
};
export function AppealIngestionModalHeader(props) {
const { headerText, subHeaderText } = props;
const styles = useStyles();
return <View style={styles.headerContainer}>
{headerText != null && headerText !== "" && <Text style={styles.header} variant="heading-xl/extrabold" color="mobile-text-heading-primary" accessibilityRole="header">{headerText}</Text>}
{subHeaderText != null ? subHeaderText.length > 0 ? <Text style={styles.subheader} variant="text-md/medium" color="text-default">{subHeaderText}</Text> : null : null}
</View>;
}
export function AppealIngestionModalScreen(props) {
let safetyHubAppealSignal, stateFromStores, stateFromStores2, navigation, setState, state, setState2, callback;
const children = props.children;
safetyHubAppealSignal = void 0;
stateFromStores = void 0;
stateFromStores2 = void 0;
navigation = void 0;
setState = void 0;
state = void 0;
setState2 = void 0;
callback = void 0;
const styles = useStyles();
const stateFromStores3 = useStateFromStores([SafetyHubStore], () => SafetyHubStore.getIsSubmitting());
safetyHubAppealSignal = useSafetyHubAppealSignal();
stateFromStores = useStateFromStores([SafetyHubStore], () => SafetyHubStore.getFreeTextAppealReason());
stateFromStores2 = useStateFromStores([SafetyHubStore], () => SafetyHubStore.getAppealClassificationId());
const safetyHubClassification = useSafetyHubClassification(stateFromStores2 == null ? EMPTY_STRING_SNOWFLAKE_ID : stateFromStores2);
const r51 = safetyHubClassification.classification?.is_spam || false;
const r54 = safetyHubClassification.classification?.is_coppa || false;
const appeal_ingestion_type = safetyHubClassification.classification?.appeal_ingestion_type;
navigation = useNavigation();
const r11 = appeal_ingestion_type != null && appeal_ingestion_type !== AppealIngestionType.IN_APP || r54 || r51;
let r65 = !r11;
let state2;
[state2, setState] = useState("");
[state, setState2] = useState("");
useEffect(() => {
let c26939_0 = navigation.addListener("state", () => {
setState2(navigation.getState().routes[navigation.getState().routes.length - 1].name);
});
return () => {
navigation.removeListener("state", c26939_0);
};
}, [navigation]);
callback = useCallback(() => {
if (state === AppealIngestionSections.SPEED_BUMP) {
navigation.push(AppealIngestionSections.COLLECT_SIGNAL);
} else if (state === AppealIngestionSections.COLLECT_SIGNAL) {
navigation.push(AppealIngestionSections.CONFIRM_SUBMISSION);
} else if (state === AppealIngestionSections.CONFIRM_SUBMISSION) {
navigation.push(AppealIngestionSections.REQUEST_SENT);
} else {
AppealIngestionModalActionCreators.close();
}
}, [navigation, state]);
const callback2 = useCallback(async () => {
let c26940_2;
let c26940_3 = 0;
let c30349_0;
L13: {
try {
if (stateFromStores2 !== null) {
c26940_3 = 1;
setState("");
await requestReview(stateFromStores2, safetyHubAppealSignal, stateFromStores);
(0, callback)();
c26940_3 = 0;
break L13;
}
} catch ($e) {
const r28 = $e;
let r7 = r28;
c26940_2 = r28;
if (c26940_3 !== 0) {
while (true) {
try {
const r68 = c26940_2;
c26940_3 = 0;
c30349_0 = r68;
setState(getRequestReviewErrorFromCode(c30349_0.body?.code));
break L13;
} catch (r64) {
r7 = r64;
c26940_2 = r64;
if (c26940_3 === 0) {
break;
}
}
}
}
throw r7;
}
return void 0;
}
}, [stateFromStores2, safetyHubAppealSignal, stateFromStores, callback]);
const r91 = [children, ,];
const r98 = [<View style={styles.separator} />, ,];
if (!r11) {
r65 = <SafeAreaPaddingView bottom style={styles.footerButton}>
{state === AppealIngestionSections.CONFIRM_SUBMISSION ? <>
<Text variant="text-xs/medium" color="text-default" style={styles.footerText}>
{intl.string(t["d6qgY/"])}
</Text>
{state2 !== "" && <Text variant="text-xs/medium" color="text-feedback-critical" style={styles.footerText}>{state2}</Text>}
<Button onPress={callback2} text={intl.string(t.geKm7t)} variant="destructive" loading={stateFromStores3} disabled={stateFromStores3} />
</> : <Button onPress={callback} text={state !== AppealIngestionSections.REQUEST_SENT && state !== AppealIngestionSections.THANKS ? intl.string(t.XiOHRX) : intl.string(t.i4jeWR)} />}
</SafeAreaPaddingView>;
}
r98[1] = r65;
r91[1] = <View style={styles.footerContainer}>{r98}</View>;
return <View style={styles.container}>{r91}</View>;
}