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

160 lines
5.8 KiB
TypeScript

// Metro module 11042 (f11043).
import { memo, useRef, useState, useCallback } from "react";
import { Image as Image2, ScrollView, View } from "react-native";
import GuildStore from "../../../stores/GuildStore";
import UserStore from "../../../stores/UserStore";
import { intl, t } from "../../../intl/index.native";
import Durations from "../../../utils/Durations";
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 { useStateFromStores } from "../../../_bundle/Module589";
import GuildActionCreators from "../../../actions/GuildActionCreators";
import Module11043 from "../../../_bundle/Module11043";
import { Text } from "../../../design/components/Text/native/Text";
import UserUtils from "../../../utils/UserUtils";
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 c7447_13 = [{
value: 0,
getLabel: () => intl.string(t["4obaMS"])
}, {
value: 1 * Durations.Seconds.HOUR,
getLabel: () => intl.string(t.RKpitY)
}, {
value: 6 * Durations.Seconds.HOUR,
getLabel: () => intl.string(t["8WfJZ8"])
}, {
value: 12 * Durations.Seconds.HOUR,
getLabel: () => intl.string(t.p1up7u)
}, {
value: 1 * Durations.Seconds.DAY,
getLabel: () => intl.string(t.XuVkkD)
}, {
value: 3 * Durations.Seconds.DAY,
getLabel: () => intl.string(t["gMcDS+"])
}, {
value: 7 * Durations.Seconds.DAY,
getLabel: () => intl.string(t.FA7IUk)
}];
useStyles = createStyles({
container: {
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
},
iconLabelBlock: {
marginTop: Module712.space.PX_16,
backgroundColor: Module712.colors.BACKGROUND_SURFACE_HIGH,
borderRadius: Module712.radii.lg,
paddingTop: Module712.space.PX_8,
paddingBottom: Module712.space.PX_16,
alignItems: "center"
},
iconStyles: {
height: 1.25 * Module712.space.PX_96
},
blurb: {
marginVertical: Module712.space.PX_16
},
redText: {
marginTop: Module712.space.PX_12,
marginBottom: Module712.space.PX_4,
color: Module712.colors.TEXT_FEEDBACK_CRITICAL
},
errorText: {
marginBottom: Module712.space.PX_16
}
});
const r144 = memo(function BanConfirm(props) {
let stateFromStores2, ref, ref2, setState;
const { guildId, userId, onBan } = props;
stateFromStores2 = void 0;
ref = void 0;
ref2 = void 0;
setState = void 0;
const styles = useStyles();
const ref3 = useRef(null);
const ref4 = useRef(null);
const insets = useSafeAreaInsetsKeyboardAware_native({
includeKeyboardHeight: true
}).insets;
useSafeAreaAvoidingInputs_native({
insets,
inputs: [{
ref: ref4,
offset: {
type: "toBottom"
}
}],
scrollViewRef: ref3
});
const stateFromStores = useStateFromStores([GuildStore], () => GuildStore.getGuild(guildId));
stateFromStores2 = useStateFromStores([UserStore], () => UserStore.getUser(userId));
ref = useRef(0);
ref2 = useRef("");
let state;
[state, setState] = useState(() => ({
banning: false,
banError: false
}));
const callback = useCallback(() => {
if (stateFromStores != null && stateFromStores2 != null) {
setState({
banning: true,
banError: false
});
GuildActionCreators.banUser(stateFromStores.id, stateFromStores2.id, c7447_13[ref.current].value, ref2.current).then(onBan).catch(() => {
setState({
banning: false,
banError: true
});
});
}
}, [stateFromStores, stateFromStores2, onBan]);
return stateFromStores2 != null ? stateFromStores != null ? <ScrollView style={styles.container} ref={ref3} contentContainerStyle={{
paddingHorizontal: Module712.space.PX_24,
paddingBottom: insets.bottom
}}>
<>
<View style={styles.iconLabelBlock}>
<Image2 style={styles.iconStyles} source={Module11043} resizeMode="contain" />
<Text style={styles.redText} variant="text-md/semibold">
{intl.format(t.Qd6w7T, {
username: UserUtils.getName(stateFromStores2)
})}
</Text>
<Text variant="text-lg/bold" color="text-feedback-warning">{stateFromStores.name}</Text>
</View>
<Text style={styles.blurb} variant="heading-md/normal" color="text-feedback-warning">
{intl.format(t["8jV9fx"], {
user: UserUtils.getName(stateFromStores2)
})}
</Text>
<TableRadioGroup title={intl.string(t["8l3W0y"])} defaultValue={c7447_13[0].value} onChange={(event) => {
ref.current = event;
}} hasIcons={false}>
{c7447_13.map((item, index) => <TableRadioRow key={index} value={index} label={item.getLabel()} />)}
</TableRadioGroup>
<TextArea ref={ref4} containerStyle={{
marginVertical: Module712.space.PX_16
}} label={intl.string(t.w4Ivys)} maxLength={512} onChange={(event) => {
ref2.current = event;
}} />
<View style={{
marginBottom: Module712.space.PX_16
}}>
<Button variant="destructive" text={intl.string(t["5MBJ5M"])} onPress={callback} disabled={state.banning} />
</View>
{state.banError ? <Text style={styles.errorText} variant="text-md/semibold" color="input-text-error-default">
{intl.format(t["/K6eer"], {
user: UserUtils.getName(stateFromStores2)
})}
</Text> : null}
</>
</ScrollView> : null : null;
});
export default r144;