Even more le fixes

This commit is contained in:
2025-10-14 02:38:31 -04:00
parent 54d9bd5e82
commit 243a4d1ceb

View File

@@ -47,6 +47,7 @@ export async function loader({ context }: { context: RequestContext }) {
export default function () {
const data: { [k: string]: any }[] = useLoaderData<typeof loader>();
const [gameModData, setGameModData] = useState(data);
const { isOpen, onClose, onOpen } = useDisclosure();
const [idToAdd, setIdToAdd] = useState<string>("");
const [nameToAdd, setNameToAdd] = useState<string>("");
@@ -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 (
<Container maxW="container.lg">
<TableContainer>
@@ -102,7 +131,7 @@ export default function () {
</Tr>
</Thead>
<Tbody>
{data.map((item) => {
{gameModData.map((item) => {
return (
<Tr key={item.metadata.id}>
<Td>{item.metadata.id}</Td>