Properly clear user list on close

This commit is contained in:
regalijan 2023-10-19 16:50:49 -04:00
parent fa28e7b37f
commit 3dfa0ce86d
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -20,7 +20,7 @@ import {
Thead, Thead,
Tr, Tr,
VStack, VStack,
useToast, useToast
} from "@chakra-ui/react"; } from "@chakra-ui/react";
import { useState } from "react"; import { useState } from "react";
@ -42,7 +42,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
png: "image/png", png: "image/png",
webp: "image/webp", webp: "image/webp",
webm: "video/webm", webm: "video/webm",
wmv: "video/x-ms-wmv", wmv: "video/x-ms-wmv"
}; };
function addUser(user: string) { function addUser(user: string) {
@ -98,19 +98,19 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
bypass: true, bypass: true,
filename: evidence.name, filename: evidence.name,
filesize: evidence.size, filesize: evidence.size,
usernames, usernames
}), }),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json"
}, },
method: "POST", method: "POST"
}); });
if (!submitReq.ok) { if (!submitReq.ok) {
toast({ toast({
description: ((await submitReq.json()) as { error: string }).error, description: ((await submitReq.json()) as { error: string }).error,
status: "error", status: "error",
title: "Failed to submit report", title: "Failed to submit report"
}); });
return; return;
@ -125,24 +125,24 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
evidence.type || evidence.type ||
fileTypes[ fileTypes[
evidence.name.split(".")[evidence.name.split(".").length - 1] evidence.name.split(".")[evidence.name.split(".").length - 1]
], ]
}, },
method: "PUT", method: "PUT"
}); });
if (!fileUpload.ok) { if (!fileUpload.ok) {
await fetch("/api/reports/recall", { await fetch("/api/reports/recall", {
body: JSON.stringify({ id }), body: JSON.stringify({ id }),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json"
}, },
method: "POST", method: "POST"
}); });
toast({ toast({
description: "Failed to upload file", description: "Failed to upload file",
status: "error", status: "error",
title: "Error", title: "Error"
}); });
return; return;
@ -151,15 +151,15 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
await fetch("/api/reports/complete", { await fetch("/api/reports/complete", {
body: JSON.stringify({ id }), body: JSON.stringify({ id }),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json"
}, },
method: "POST", method: "POST"
}); });
toast({ toast({
description: "User moderated", description: "User moderated",
status: "success", status: "success",
title: "Success", title: "Success"
}); });
} }
@ -168,7 +168,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
<ModalOverlay /> <ModalOverlay />
<ModalContent> <ModalContent>
<ModalHeader>New Game Ban</ModalHeader> <ModalHeader>New Game Ban</ModalHeader>
<ModalCloseButton /> <ModalCloseButton onClick={reset} />
<ModalBody> <ModalBody>
<Text>Username(s)</Text> <Text>Username(s)</Text>
<Input id="username" mb="8px" placeholder="builderman" /> <Input id="username" mb="8px" placeholder="builderman" />
@ -191,7 +191,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
duration: 5000, duration: 5000,
isClosable: true, isClosable: true,
status: "error", status: "error",
title: "Invalid Username", title: "Invalid Username"
}); });
return; return;
} }
@ -220,7 +220,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
<RadioGroup <RadioGroup
onChange={(val) => onChange={(val) =>
Object.defineProperty(actionMap, user, { Object.defineProperty(actionMap, user, {
value: parseInt(val), value: parseInt(val)
}) })
} }
> >