diff --git a/src/controllers/modals/ModalController.tsx b/src/controllers/modals/ModalController.tsx index 8080f786..feebb85e 100644 --- a/src/controllers/modals/ModalController.tsx +++ b/src/controllers/modals/ModalController.tsx @@ -16,6 +16,7 @@ import { getApplicationState } from "../../mobx/State"; import { history } from "../../context/history"; import AddFriend from "./components/AddFriend"; +import BanMember from "./components/BanMember"; import Changelog from "./components/Changelog"; import ChannelInfo from "./components/ChannelInfo"; import Clipboard from "./components/Clipboard"; @@ -28,6 +29,7 @@ import CustomStatus from "./components/CustomStatus"; import DeleteMessage from "./components/DeleteMessage"; import Error from "./components/Error"; import ImageViewer from "./components/ImageViewer"; +import KickMember from "./components/KickMember"; import LinkWarning from "./components/LinkWarning"; import MFAEnableTOTP from "./components/MFAEnableTOTP"; import MFAFlow from "./components/MFAFlow"; @@ -236,6 +238,7 @@ class ModalControllerExtended extends ModalController { export const modalController = new ModalControllerExtended({ add_friend: AddFriend, + ban_member: BanMember, changelog: Changelog, channel_info: ChannelInfo, clipboard: Clipboard, @@ -256,6 +259,7 @@ export const modalController = new ModalControllerExtended({ delete_message: DeleteMessage, error: Error, image_viewer: ImageViewer, + kick_member: KickMember, link_warning: LinkWarning, mfa_flow: MFAFlow, mfa_recovery: MFARecovery, diff --git a/src/controllers/modals/components/BanMember.tsx b/src/controllers/modals/components/BanMember.tsx new file mode 100644 index 00000000..640d9ce9 --- /dev/null +++ b/src/controllers/modals/components/BanMember.tsx @@ -0,0 +1,46 @@ +import { Text } from "preact-i18n"; + +import { Column, ModalForm } from "@revoltchat/ui"; + +import UserIcon from "../../../components/common/user/UserIcon"; +import { ModalProps } from "../types"; + +/** + * Ban member modal + */ +export default function BanMember({ + member, + ...props +}: ModalProps<"ban_member">) { + return ( + } + schema={{ + member: "custom", + reason: "text", + }} + data={{ + member: { + element: ( + + + + + ), + }, + reason: { + field: ( + + ) as React.ReactChild, + }, + }} + callback={async ({ reason }) => + void (await member.server!.banUser(member._id.user, { reason })) + } + /> + ); +} diff --git a/src/controllers/modals/components/KickMember.tsx b/src/controllers/modals/components/KickMember.tsx new file mode 100644 index 00000000..8631d519 --- /dev/null +++ b/src/controllers/modals/components/KickMember.tsx @@ -0,0 +1,38 @@ +import { Text } from "preact-i18n"; + +import { Column, ModalForm } from "@revoltchat/ui"; + +import UserIcon from "../../../components/common/user/UserIcon"; +import { ModalProps } from "../types"; + +/** + * Kick member modal + */ +export default function KickMember({ + member, + ...props +}: ModalProps<"kick_member">) { + return ( + } + schema={{ + member: "custom", + }} + data={{ + member: { + element: ( + + + + + ), + }, + }} + callback={() => member.kick()} + /> + ); +}