diff --git a/app/routes/mod-queue.tsx b/app/routes/mod-queue.tsx index 1c5698f..2246f8f 100644 --- a/app/routes/mod-queue.tsx +++ b/app/routes/mod-queue.tsx @@ -30,7 +30,6 @@ import { useLoaderData } from "@remix-run/react"; import AppealBans from "../../components/AppealBans.js"; import AppealCard from "../../components/AppealCard.js"; import GameAppealCard from "../../components/GameAppealCard.js"; -import GameModManagementModal from "../../components/GameModManagementModal.js"; import NewGameBan from "../../components/NewGameBan.js"; import NewInfractionModal from "../../components/NewInfractionModal.js"; import ReportCard from "../../components/ReportCard.js"; @@ -151,7 +150,7 @@ export default function () { useEffect(() => { if (messageChannel.current) { - messageChannel.current.port1.onmessage = function (ev) { + messageChannel.current.port1.onmessage = function (ev: any) { const { data }: { data: string } = ev; setEntries([...entries].filter((entry) => entry.id !== data)); @@ -337,7 +336,11 @@ export default function () { }, appeal_bans: useDisclosure(), game_ban: useDisclosure(), - gme: useDisclosure(), + gme: { + isOpen: false, + onClose: () => {}, + onOpen: () => location.assign("/gmm"), + }, inactivity: useDisclosure(), infraction: useDisclosure(), user_lookup: { @@ -431,10 +434,6 @@ export default function () { isOpen={itemModals.appeal_bans.isOpen} onClose={itemModals.appeal_bans.onClose} /> - void }) { - const [mods, setMods] = useState([]); - const [userToAdd, setUserToAdd] = useState(""); - const toast = useToast(); - - useEffect(() => { - if (!props.isOpen) return; - - (async function () { - const gmeResp = await fetch("/api/gme/list"); - - if (!gmeResp.ok) { - toast({ - description: "Failed to load GME data", - status: "error", - title: "Oops", - }); - - return; - } - - setMods(await gmeResp.json()); - })(); - }, [props.isOpen]); - - async function addUser() { - if (!userToAdd || !userToAdd.match(/^\d{17,19}$/)) { - toast({ - description: "Please check your input and try again", - status: "error", - title: "Invalid user", - }); - - return; - } - - const addResp = await fetch("/api/gme/add", { - body: JSON.stringify({ user: userToAdd }), - headers: { - "content-type": "application/json", - }, - method: "POST", - }); - - if (!addResp.ok) { - toast({ - description: ((await addResp.json()) as { error: string }).error, - status: "error", - title: "Oops", - }); - - return; - } - - toast({ - description: `User ${userToAdd} added`, - status: "success", - title: "Success", - }); - - props.onClose(); - } - - async function removeUser(user: string) { - const removeResp = await fetch("/api/gme/remove", { - body: JSON.stringify({ user }), - headers: { - "content-type": "application/json", - }, - method: "POST", - }); - - if (!removeResp.ok) { - toast({ - description: ((await removeResp.json()) as { error: string }).error, - status: "error", - title: "Oops", - }); - } else { - toast({ - description: `User ${user} removed`, - status: "success", - title: "Success", - }); - - setMods(mods.filter((mod: any) => mod.user !== user)); - } - } - - return ( - - - - Game Moderators - - - - - - - - - - - - - - {mods.map((mod: any) => ( - - - - - - - ))} - -
UserAdded AtAdded ByRemove
{mod.user}{new Date(mod.metadata.time).toLocaleString()}{mod.metadata.user} - await removeUser(mod.user)}> - Remove - -
-
- - setUserToAdd(e.target.value)} - placeholder="1234567890987654321" - /> - - -
-
-
- ); -} diff --git a/functions/api/gme/list.ts b/functions/api/gme/list.ts deleted file mode 100644 index 0d3a2ad..0000000 --- a/functions/api/gme/list.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { jsonResponse } from "../../common.js"; - -export async function onRequestGet(context: RequestContext) { - const list = await context.env.DATA.list({ prefix: "gamemod_" }); - const entries = []; - - for (const key of list.keys) - entries.push({ - metadata: key.metadata, - user: key.name.replace("gamemod_", ""), - }); - - return jsonResponse(JSON.stringify(entries)); -}