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

136 lines
5.7 KiB
TypeScript

// Metro module 16295 (f16296).
import { useEffect, useRef, useCallback } from "react";
import { View } from "react-native";
import FamilyCenterStore from "../FamilyCenterStore";
import { FamilyCenterSubPages, UserLinkStatus, UserLinkType } from "../FamilyCenterConstants";
import { AnalyticEvents, UserSettingsSections } from "../../../Constants";
import { ContentDismissActionType } from "../../dismissible_content/DismissibleContentConstants";
import { DismissibleContent } from "../../../_bundle/Module1358";
import FamilyCenterActionCreators from "../FamilyCenterActionCreators";
import { getRootNavigationRef } from "../../main_tabs_v2/RootNavigationRef.native";
import { openUserSettings } from "../../user_settings/core/native/openUserSettings";
import ModalDispatchQueue from "../../main_tabs_v2/native/modal/ModalDispatchQueue";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useSafeAreaInsets_native from "../../safe_area/useSafeAreaInsets.native";
import { useSyncMessages, intl } from "../../../intl/index.native";
import FamilyCenter_messages, { messagesLoader } from "../FamilyCenter.messages";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import Dispatcher from "../../../Dispatcher";
import { markTimeRecurringDismissibleContentAsDismissed } from "../../dismissible_content/DismissibleContentUtils";
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
import ModalActionCreators from "../../../actions/ModalActionCreators";
import { BottomSheet } from "../../../design/components/Sheet/native/BottomSheet.native";
import { Stack } from "../../../design/components/Stack/native/Stack.native";
import { FamilyKeysSpotIllustration } from "../../../design/assets/native";
import { Text } from "../../../design/components/Text/native/Text";
import { Button } from "../../../design/components/Button/native/Button.native";
const surface_type = "modal";
const PARENTAL_CONSENT_GRACE_WARNING = DismissibleContent.PARENTAL_CONSENT_GRACE_WARNING;
const useStyles = createStyles({
container: {
paddingHorizontal: Module712.space.PX_16
},
illustration: {
alignItems: "center",
paddingTop: Module712.space.PX_12
},
title: {
textAlign: "center"
},
body: {
textAlign: "center"
}
});
export default function ParentalConsentWarningModal(props) {
let ref, callback, callback2;
const daysRemaining = props.daysRemaining;
ref = void 0;
callback = void 0;
callback2 = void 0;
const styles = useStyles();
const bottom = useSafeAreaInsets_native().bottom;
useSyncMessages(messagesLoader);
const r3 = daysRemaining === 0;
useEffect(() => {
AnalyticsUtils.track(AnalyticEvents.PARENTAL_CONSENT_WARNING_SURFACE_SHOWN, {
surface_type,
days_remaining: daysRemaining
});
Dispatcher.dispatch({
type: "PARENTAL_CONSENT_WARNING_MODAL_SHOWN"
});
}, []);
ref = useRef(false);
callback = useCallback(() => {
const current = ref.current;
let r0 = !current;
if (!current) {
ref.current = true;
markTimeRecurringDismissibleContentAsDismissed(PARENTAL_CONSENT_GRACE_WARNING, {
dismissAction: ContentDismissActionType.USER_DISMISS
});
r0 = true;
}
return r0;
}, []);
callback2 = useCallback(() => {
if (callback()) {
AnalyticsUtils.track(AnalyticEvents.PARENTAL_CONSENT_WARNING_SURFACE_DISMISSED, {
surface_type,
days_remaining: daysRemaining
});
}
}, [daysRemaining, callback]);
const callback4 = useCallback(() => {
callback2();
ActionSheetActionCreators.hideActionSheet();
}, [callback2]);
const callback3 = useCallback(() => {
L6: {
callback();
ActionSheetActionCreators.hideActionSheet();
if (Object.values(FamilyCenterStore.getLinkedUsers()).some((item) => item.link_status === UserLinkStatus.PENDING && item.link_type === UserLinkType.PARENT)) {
FamilyCenterActionCreators.selectTab(FamilyCenterSubPages.REQUESTS);
const rootNavigationRef = getRootNavigationRef();
if (rootNavigationRef != null && rootNavigationRef.isReady()) {
openUserSettings({
screen: UserSettingsSections.FAMILY_CENTER
});
break L6;
}
ModalDispatchQueue.enqueue(() => openUserSettings({
screen: UserSettingsSections.FAMILY_CENTER
}));
} else {
ModalActionCreators.pushLazy(import("./ConnectGuardianShareModal"));
}
}
}, [callback]);
return <BottomSheet startExpanded onDismiss={callback2}>
<View style={[styles.container, {
paddingBottom: bottom
}]}>
<Stack spacing={Module712.space.PX_16}>
<View style={styles.illustration}>
<FamilyKeysSpotIllustration accessible={false} />
</View>
<Text variant="heading-lg/bold" color="text-default" style={styles.title} accessibilityRole="header">
{r3 ? intl.string(FamilyCenter_messages.Zo5YZD) : intl.formatToPlainString(FamilyCenter_messages.b4sYUn, {
count: daysRemaining
})}
</Text>
<Text variant="text-md/medium" color="text-default" style={styles.body}>
{r3 ? intl.string(FamilyCenter_messages.CRZBSY) : intl.formatToPlainString(FamilyCenter_messages.mQcGGY, {
count: daysRemaining
})}
</Text>
<Stack spacing={Module712.space.PX_8}>
<Button size="lg" variant="primary" grow text={intl.string(FamilyCenter_messages.Kp7sjX)} onPress={callback3} />
<Button size="lg" variant="secondary" grow text={intl.string(FamilyCenter_messages.hST5o8)} accessibilityHint={intl.string(FamilyCenter_messages["4fZtHa"])} onPress={callback4} />
</Stack>
</Stack>
</View>
</BottomSheet>;
};