From 243a4d1cebbb9c7d66c5002589905d8fad39de39 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Tue, 14 Oct 2025 02:38:31 -0400 Subject: [PATCH] Even more le fixes --- app/routes/gmm.tsx | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/app/routes/gmm.tsx b/app/routes/gmm.tsx index a4dbe99..2b0396f 100644 --- a/app/routes/gmm.tsx +++ b/app/routes/gmm.tsx @@ -47,6 +47,7 @@ export async function loader({ context }: { context: RequestContext }) { export default function () { const data: { [k: string]: any }[] = useLoaderData(); + const [gameModData, setGameModData] = useState(data); const { isOpen, onClose, onOpen } = useDisclosure(); const [idToAdd, setIdToAdd] = useState(""); const [nameToAdd, setNameToAdd] = useState(""); @@ -74,11 +75,6 @@ export default function () { title: "Cannot add game mod", }); } else { - toast({ - description: `${name} was added as a game mod`, - status: "success", - title: "Game mod added", - }); onClose(); location.reload(); } @@ -87,6 +83,39 @@ export default function () { setNameToAdd(""); } + async function removeMod(user: string) { + const response = await fetch("/api/gme/remove", { + body: JSON.stringify({ user }), + headers: { + "content-type": "application/json", + }, + method: "POST", + }); + + if (!response.ok) { + let msg = "Unknown error"; + + try { + msg = ((await response.json()) as { error: string }).error; + } catch {} + toast({ + description: msg, + status: "error", + title: "Cannot remove game mod", + }); + + return; + } + + toast({ + description: `${data.find((i) => i.metadata.id === user)?.name} was removed as a game mod`, + status: "success", + title: "Game mod removed", + }); + + setGameModData(gameModData.filter((i) => i.metadata.id !== user)); + } + return ( @@ -102,7 +131,7 @@ export default function () { - {data.map((item) => { + {gameModData.map((item) => { return ( {item.metadata.id}