101 lines
4.3 KiB
TypeScript
101 lines
4.3 KiB
TypeScript
// Metro module 13780 (f13781).
|
|
import { useEffect } from "react";
|
|
import { ActivityIndicator, ScrollView, View } from "react-native";
|
|
import SafetyHubStore from "../SafetyHubStore";
|
|
import { AgeCheckStatus } from "../SafetyHubConstants";
|
|
import { AnalyticEvents, Routes } from "../../../Constants";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import AuthenticationActionCreators from "../../../actions/AuthenticationActionCreators";
|
|
import { HelpMessageTypes, HelpMessage } from "../../../design/void/native";
|
|
import { useStateFromStores } from "../../../_bundle/Module589";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import useSafetyHubLoading from "../hooks/useSafetyHubLoading";
|
|
import { useSafetyHubInitialized } from "../hooks/useSafetyHubInitialized";
|
|
import { useSafetyHubAccountStanding } from "../hooks/useSafetyHubAccountStanding";
|
|
import { useSafetyHubFetchError } from "../hooks/useSafetyHubFetchError";
|
|
import useMountEffect from "../../../hooks/useMountEffect";
|
|
import { getSafetyHubData } from "../SafetyHubActionCreators";
|
|
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
|
|
import MonitoringAgent from "../../monitoring/MonitoringAgent";
|
|
import { MetricEvents } from "../../../_bundle/Module5872";
|
|
import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators";
|
|
import SafetyHubAccountStanding from "./SafetyHubAccountStanding";
|
|
import { ConnectedSafetyHubViolationsContainer } from "./SafetyHubViolationsContainer";
|
|
let useStyles;
|
|
const AutomatedUnderageAppealStatus = function AutomatedUnderageAppealStatus() {
|
|
const stateFromStores = useStateFromStores([SafetyHubStore], () => SafetyHubStore.getAgeCheckStatus());
|
|
const r20 = AgeCheckStatus.SUCCESS === stateFromStores ? {
|
|
message: intl.format(t.hyh4ls, {
|
|
loginHook: (a0) => <Text variant="text-sm/medium" color="text-link" onPress={() => AuthenticationActionCreators.logout("safety_hub_page_appeal_success", Routes.LOGIN)}>
|
|
{a0}
|
|
</Text>
|
|
}),
|
|
type: HelpMessageTypes.SUCCESS
|
|
} : AgeCheckStatus.ERROR === stateFromStores ? {
|
|
message: intl.string(t["4sILBU"]),
|
|
type: HelpMessageTypes.ERROR
|
|
} : AgeCheckStatus.FAILURE === stateFromStores ? {
|
|
message: intl.string(t["40R63o"]),
|
|
type: HelpMessageTypes.ERROR
|
|
} : AgeCheckStatus.LOADING === stateFromStores ? {
|
|
message: intl.string(t["nhhy/R"]),
|
|
type: HelpMessageTypes.INFO
|
|
} : {
|
|
message: null,
|
|
type: null
|
|
};
|
|
const { message, type } = r20;
|
|
return type != null ? <HelpMessage messageType={type}>{message}</HelpMessage> : null;
|
|
};
|
|
useStyles = createStyles({
|
|
container: {
|
|
paddingHorizontal: Module712.space.PX_12,
|
|
paddingVertical: Module712.space.PX_12
|
|
},
|
|
loadingIndicator: {
|
|
display: "flex",
|
|
justifyContent: "center",
|
|
alignItems: "center"
|
|
},
|
|
body: {
|
|
gap: Module712.space.PX_8
|
|
}
|
|
});
|
|
export default function SafetyHubPage(props) {
|
|
const visible = props.visible;
|
|
const styles = useStyles();
|
|
const safetyHubLoading = useSafetyHubLoading();
|
|
const safetyHubInitialized = useSafetyHubInitialized();
|
|
const safetyHubAccountStanding = useSafetyHubAccountStanding();
|
|
const safetyHubFetchError = useSafetyHubFetchError();
|
|
useMountEffect(() => {
|
|
getSafetyHubData();
|
|
if (safetyHubInitialized) {
|
|
AnalyticsUtils.track(AnalyticEvents.SAFETY_HUB_VIEWED, {
|
|
account_standing: safetyHubAccountStanding.state
|
|
});
|
|
MonitoringAgent.increment({
|
|
name: MetricEvents.SAFETY_HUB_VIEW
|
|
});
|
|
}
|
|
});
|
|
useEffect(() => {
|
|
if (visible && safetyHubFetchError != null) {
|
|
ActionSheetActionCreators.openLazy(import("./SafetyHubErrorActionSheet"), "SafetyHubErrorActionSheet", {});
|
|
} else {
|
|
ActionSheetActionCreators.hideActionSheet("SafetyHubErrorActionSheet");
|
|
}
|
|
}, [safetyHubFetchError, visible]);
|
|
return safetyHubLoading ? <View style={[styles.container, styles.loadingIndicator]}>
|
|
<ActivityIndicator animating size="large" />
|
|
</View> : safetyHubFetchError == null ? <ScrollView style={styles.container}>
|
|
<View style={styles.body}>
|
|
<AutomatedUnderageAppealStatus />
|
|
<SafetyHubAccountStanding />
|
|
</View>
|
|
<ConnectedSafetyHubViolationsContainer />
|
|
</ScrollView> : null;
|
|
};
|