import { createFormControl, createFormGroup } from "solid-forms"; import { Trans, useLingui } from "@lingui-solid/solid/macro"; import { Avatar, Column, Dialog, DialogProps, Form2, Text } from "@revolt/ui"; import { useModals } from ".."; import { Modals } from "../types"; /** * Ban a server non-member with reason */ export function BanNonMemberModal( props: DialogProps & Modals & { type: "ban_non_member" }, ) { const { t } = useLingui(); const { showError } = useModals(); const group = createFormGroup({ reason: createFormControl(""), }); async function onSubmit() { try { await props.server.banUser(props.user.id, { reason: group.controls.reason.value, }); props.onClose(); } catch (error) { showError(error); } } const submit = Form2.useSubmitHandler(group, onSubmit); return ( Ban User} actions={[ { text: Cancel }, { text: Ban, onClick: () => { onSubmit(); return false; }, isDisabled: !Form2.canSubmit(group), }, ]} isDisabled={group.isPending} >
You are about to ban {props.user?.username} This user is not part of the server and may already be banned
); }