(undefined);
return (
}
actions={[
{
children: (
),
contrast: true,
error: true,
confirmation: true,
onClick: async () => {
setProcessing(true);
try {
await props.target.banUser(props.user._id, {
reason,
});
onClose();
} catch (err) {
setError(takeError(err));
setProcessing(false);
}
},
},
{
children: (
),
onClick: onClose,
},
]}
content={
setReason(e.currentTarget.value)
}
/>
}
disabled={processing}
error={error}
/>
);
}
case "create_channel": {
const [name, setName] = useState("");
const [type, setType] = useState<"Text" | "Voice">("Text");
const history = useHistory();
return (
}
actions={[
{
confirmation: true,
contrast: true,
children: (
),
onClick: async () => {
setProcessing(true);
try {
const channel =
await props.target.createChannel({
type,
name,
nonce: ulid(),
});
if (props.cb) {
props.cb(channel);
} else {
history.push(
`/server/${props.target._id}/channel/${channel._id}`,
);
}
onClose();
} catch (err) {
setError(takeError(err));
setProcessing(false);
}
},
},
{
children: (
),
onClick: onClose,
},
]}
content={
<>
setType("Text")}>
setType("Voice")}>
setName(e.currentTarget.value)}
/>
>
}
disabled={processing}
error={error}
/>
);
}
case "create_category": {
const [name, setName] = useState("");
return (
}
actions={[
{
confirmation: true,
contrast: true,
children: (
),
onClick: async () => {
setProcessing(true);
try {
props.target.edit({
categories: [
...(props.target.categories ?? []),
{
id: ulid(),
title: name,
channels: [],
},
],
});
onClose();
setProcessing(false);
} catch (err) {
setError(takeError(err));
setProcessing(false);
}
},
},
{
children: (
),
onClick: onClose,
},
]}
content={
<>
setName(e.currentTarget.value)}
/>
>
}
disabled={processing}
error={error}
/>
);
}
default:
return null;
}
});