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

148 lines
5.3 KiB
TypeScript

// Metro module 11032 (f11033).
import { memo, useState, useRef } from "react";
import { ScrollView, View } from "react-native";
import { GUILD_COMMUNICATION_DISABLED_RESOURCE_LINK, SET_COMMUNICATION_DISABLED_MODAL_NAME, DisableCommunicationDuration } from "../GuildDisableCommunicationConstants";
import { AnalyticEvents } from "../../../Constants";
import { intl, t } from "../../../intl/index.native";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module712 from "../../../_bundle/Module712";
import useSafeAreaInsetsKeyboardAware_native from "../../safe_area/useSafeAreaInsetsKeyboardAware.native";
import useSafeAreaAvoidingInputs_native from "../../safe_area/useSafeAreaAvoidingInputs.native";
import useMountEffect from "../../../hooks/useMountEffect";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import CommunicationDisabledActionCreators from "../../../actions/CommunicationDisabledActionCreators";
import ToastActionCreators from "../../toast/native/ToastActionCreators";
import NicknameUtils from "../../../utils/NicknameUtils";
import Module10356 from "../../../_bundle/Module10356";
import { Text } from "../../../design/components/Text/native/Text";
import { TableRadioGroup } from "../../../design/components/TableRow/native/TableRadioGroup.native";
import { TableRadioRow } from "../../../design/components/TableRow/native/TableRadioRow.native";
import { TextArea } from "../../../design/components/TextInput/native/TextArea.native";
import { Button } from "../../../design/components/Button/native/Button.native";
let useStyles;
let c7440_14 = [{
value: DisableCommunicationDuration.DURATION_60_SEC,
getLabel: () => intl.formatToPlainString(t.iruf5E, {
minutes: 1
})
}, {
value: DisableCommunicationDuration.DURATION_5_MIN,
getLabel: () => intl.formatToPlainString(t.iruf5E, {
minutes: 5
})
}, {
value: DisableCommunicationDuration.DURATION_10_MIN,
getLabel: () => intl.formatToPlainString(t.iruf5E, {
minutes: 10
})
}, {
value: DisableCommunicationDuration.DURATION_1_HOUR,
getLabel: () => intl.formatToPlainString(t.LnvrA3, {
hours: 1
})
}, {
value: DisableCommunicationDuration.DURATION_1_DAY,
getLabel: () => intl.formatToPlainString(t.jzH70Z, {
days: 1
})
}, {
value: DisableCommunicationDuration.DURATION_1_WEEK,
getLabel: () => intl.formatToPlainString(t.iVZYyl, {
weeks: 1
})
}];
useStyles = createStyles({
container: {
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
},
reasonTextArea: {
marginVertical: Module712.space.PX_16
},
buttonContainer: {
marginBottom: Module712.space.PX_16
}
});
const r77 = memo(function GuildDisableCommunication(props) {
let state, setState, ref;
const { user, guildId, onClose } = props;
state = void 0;
setState = void 0;
ref = void 0;
let _handleSubmitButtonPressed2 = function _handleSubmitButtonPressed() {
const r9 = async () => {
let c30333_1;
c30333_1 = void 0;
await CommunicationDisabledActionCreators.setCommunicationDisabledDuration(guildId, user.id, c7440_14[state].value, ref.current);
const O9C3Nt = t.O9C3Nt;
const name2 = NicknameUtils.getName(guildId, null, user);
let name = name2;
if (name2 == null) {
name = "";
}
ToastActionCreators.open({
key: "GUILD_COMMUNICATION_DISABLED_SUCCESS",
content: intl.formatToPlainString(O9C3Nt, {
user: name
}),
icon: Module10356
});
(0, onClose)();
};
_handleSubmitButtonPressed2 = r9;
return r9.apply(this, arguments);
};
const styles = useStyles();
[state, setState] = useState(0);
ref = useRef("");
const ref2 = useRef(null);
const ref3 = useRef(null);
const insets = useSafeAreaInsetsKeyboardAware_native({
includeKeyboardHeight: true
}).insets;
useSafeAreaAvoidingInputs_native({
insets,
inputs: [{
ref: ref3,
offset: {
type: "toBottom"
}
}],
scrollViewRef: ref2
});
useMountEffect(() => {
AnalyticsUtils.track(AnalyticEvents.OPEN_MODAL, {
type: SET_COMMUNICATION_DISABLED_MODAL_NAME,
guild_id: guildId,
other_user_id: user.id
});
});
return <ScrollView style={styles.container} ref={ref2} contentContainerStyle={{
paddingHorizontal: Module712.space.PX_12,
paddingBottom: insets.bottom
}}>
<>
<Text style={{
marginVertical: Module712.space.PX_16
}} variant="heading-md/semibold">
{intl.format(t.Ns83GT, {
helpdeskArticle: GUILD_COMMUNICATION_DISABLED_RESOURCE_LINK
})}
</Text>
<TableRadioGroup title={intl.string(t["9XsExm"])} defaultValue={0} onChange={(event) => {
setState(event);
}} hasIcons={false}>
{c7440_14.map((item, index) => <TableRadioRow key={index} value={index} label={item.getLabel()} />)}
</TableRadioGroup>
<TextArea ref={ref3} containerStyle={styles.reasonTextArea} placeholder={intl.string(t.GakiH1)} label={intl.string(t.ewHW15)} maxLength={512} onChange={(event) => {
ref.current = event;
}} />
<View style={styles.buttonContainer}>
<Button variant="primary" text={intl.string(t.MlPTIi)} onPress={function handleSubmitButtonPressed() {
return _handleSubmitButtonPressed2.apply(this, arguments);
}} />
</View>
</>
</ScrollView>;
});
export default r77;