revite/src/pages/settings/server/Bans.tsx

38 lines
856 B
TypeScript
Raw Normal View History

2021-06-19 22:37:12 +01:00
import { Servers } from "revolt.js/dist/api/objects";
2021-07-05 11:23:23 +01:00
2021-06-19 22:37:12 +01:00
import { useContext, useEffect, useState } from "preact/hooks";
2021-07-05 11:23:23 +01:00
2021-06-19 22:37:12 +01:00
import { AppContext } from "../../../context/revoltjs/RevoltClient";
2021-07-05 11:23:23 +01:00
import Tip from "../../../components/ui/Tip";
2021-06-19 22:37:12 +01:00
interface Props {
2021-07-05 11:23:23 +01:00
server: Servers.Server;
2021-06-19 22:37:12 +01:00
}
export function Bans({ server }: Props) {
2021-07-05 11:23:23 +01:00
const client = useContext(AppContext);
const [bans, setBans] = useState<Servers.Ban[] | undefined>(undefined);
2021-06-19 22:37:12 +01:00
2021-07-05 11:23:23 +01:00
useEffect(() => {
client.servers.fetchBans(server._id).then((bans) => setBans(bans));
}, []);
2021-06-19 22:37:12 +01:00
2021-07-05 11:23:23 +01:00
return (
<div>
<Tip warning>This section is under construction.</Tip>
{bans?.map((x) => (
<div>
{x._id.user}: {x.reason ?? "no reason"}{" "}
<button
onClick={() =>
client.servers.unbanUser(server._id, x._id.user)
}>
unban
</button>
</div>
))}
</div>
);
2021-06-19 22:37:12 +01:00
}