2021-07-01 17:36:34 +01:00
|
|
|
import Tip from "../../../components/ui/Tip";
|
2021-06-19 22:37:12 +01:00
|
|
|
import { Servers } from "revolt.js/dist/api/objects";
|
|
|
|
import { useContext, useEffect, useState } from "preact/hooks";
|
|
|
|
import { AppContext } from "../../../context/revoltjs/RevoltClient";
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
server: Servers.Server;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function Bans({ server }: Props) {
|
|
|
|
const client = useContext(AppContext);
|
|
|
|
const [bans, setBans] = useState<Servers.Ban[] | undefined>(undefined);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
client.servers.fetchBans(server._id)
|
|
|
|
.then(bans => setBans(bans))
|
|
|
|
}, [ ]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2021-07-01 17:36:34 +01:00
|
|
|
<Tip warning>This section is under construction.</Tip>
|
2021-06-19 22:37:12 +01:00
|
|
|
{ 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>
|
|
|
|
);
|
|
|
|
}
|