Skip to content

Commit db23568

Browse files
committed
2 parents 85f020d + 80b64ed commit db23568

3 files changed

Lines changed: 37 additions & 9 deletions

File tree

‎src/chat-api/services/ServerService.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ export async function kickServerMember(
8080
export async function BanServerMember(
8181
serverId: string,
8282
userId: string,
83-
shouldDeleteRecentMessages?: boolean
83+
shouldDeleteRecentMessages?: boolean,
84+
reason?: string
8485
): Promise<any> {
8586
return request({
8687
method: "POST",
@@ -89,11 +90,15 @@ export async function BanServerMember(
8990
"/api" +
9091
ServiceEndpoints.serverMemberBan(serverId, userId),
9192
params: {
92-
shouldDeleteRecentMessages, // delete messages sent in the last 7 hours.
93+
shouldDeleteRecentMessages,// delete messages sent in the last 7 hours.
94+
},
95+
body: {
96+
reason,
9397
},
9498
useToken: true,
9599
});
96100
}
101+
97102
export async function removeBanServerMember(
98103
serverId: string,
99104
userId: string

‎src/components/member-context-menu/MemberContextMenu.tsx‎

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import Input from "../ui/input/Input";
3131
import { Notice } from "../ui/Notice/Notice";
3232
import Text from "../ui/Text";
3333
import Avatar from "../ui/Avatar";
34+
import { FlexColumn } from "../ui/Flexbox";
3435
import { Modal } from "../ui/modal";
3536
import { User } from "@/chat-api/store/useUsers";
3637
import { Server } from "@/chat-api/store/useServers";
@@ -215,6 +216,7 @@ export default function MemberContextMenu(props: Props) {
215216
);
216217
}
217218

219+
218220
function Header(props: { userId: string }) {
219221
const setVoiceVolume = (volume: number) => {
220222
setCachedVolumes(props.userId, volume);
@@ -490,17 +492,19 @@ function BanModal(props: {
490492
const [requestSent, setRequestSent] = createSignal(false);
491493
const [shouldDeleteRecentMessages, setShouldDeleteRecentMessages] =
492494
createSignal<boolean>(false);
495+
const [reason, setReason] = createSignal("");
493496

494497
const onBanClick = async () => {
495498
if (requestSent()) return;
496499
setRequestSent(true);
500+
497501
await BanServerMember(
498502
props.serverId,
499503
props.user.id,
500-
shouldDeleteRecentMessages()
501-
).finally(() => {
502-
setRequestSent(false);
503-
});
504+
shouldDeleteRecentMessages(),
505+
reason() || undefined
506+
).finally(() => setRequestSent(false));
507+
504508
props.close();
505509
};
506510

@@ -522,15 +526,31 @@ function BanModal(props: {
522526
title={t("banModal.title", { username: props.user.username })}
523527
actionButtons={ActionButtons}
524528
>
525-
<div class={styles.kickModal}>
526-
<div style={{ "margin-bottom": "15px" }}>
529+
<div class={styles.kickModal} style={{ "min-width": "330px" }}>
530+
<div style={{ "margin-bottom": "18px" }}>
527531
<Trans
528532
key="banModal.message"
529533
options={{ username: props.user.username }}
530534
>
531535
Are you sure you want to ban <b>{"username"}</b>?
532536
</Trans>
533537
</div>
538+
539+
<FlexColumn style={{ "margin-bottom": "20px", width: "100%" }}>
540+
<Text size={13} opacity={0.8} style={{ "margin-bottom": "6px" }}>
541+
{t("banModal.reasonLabel") || "Reason (optional)"}
542+
</Text>
543+
<Input
544+
placeholder={t("banModal.reasonPlaceholder")}
545+
value={reason()}
546+
onInput={(e) => setReason(e.currentTarget.value)}
547+
style={{
548+
width: "100%",
549+
padding: "8px 10px",
550+
}}
551+
/>
552+
</FlexColumn>
553+
534554
<Checkbox
535555
checked={shouldDeleteRecentMessages()}
536556
onChange={setShouldDeleteRecentMessages}
@@ -541,6 +561,7 @@ function BanModal(props: {
541561
);
542562
}
543563

564+
544565
export function ServerMemberRoleModal(props: Props & { close: () => void }) {
545566
const { serverRoles, serverMembers, servers, account } = useStore();
546567
const server = () => servers.get(props.serverId!);

‎src/locales/list/en-gb.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,9 @@
648648
"message": "Are you sure you want to ban <1>{{username}}</1>?",
649649
"deletePastMessagesCheckbox": "Delete messages sent in the past 7 hours.",
650650
"banButton": "Ban",
651-
"banning": "Banning..."
651+
"banning": "Banning...",
652+
"reasonLabel": "Reason (optional)",
653+
"reasonPlaceholder": "Enter a reason…"
652654
},
653655
"messageContextMenu": {
654656
"editMessage": "Edit Message",

0 commit comments

Comments
 (0)