Le formatting fixes
This commit is contained in:
@ -20,14 +20,14 @@ import {
|
||||
Thead,
|
||||
Tr,
|
||||
VStack,
|
||||
useToast
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
export default function (props: { isOpen: boolean; onClose: () => void }) {
|
||||
const actionMap: { [k: string]: number } = {};
|
||||
const [users, setUsers] = useState([] as string[]);
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [loading, setLoading] = useState(true);
|
||||
const toast = useToast();
|
||||
const fileTypes: { [k: string]: string } = {
|
||||
gif: "image/gif",
|
||||
@ -43,15 +43,14 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
png: "image/png",
|
||||
webp: "image/webp",
|
||||
webm: "video/webm",
|
||||
wmv: "video/x-ms-wmv"
|
||||
wmv: "video/x-ms-wmv",
|
||||
};
|
||||
|
||||
function addUser(user: string) {
|
||||
(document.getElementById("username") as HTMLInputElement).value = "";
|
||||
const newUsers = [...users];
|
||||
|
||||
if (newUsers.includes(user))
|
||||
return;
|
||||
if (newUsers.includes(user)) return;
|
||||
|
||||
newUsers.push(user);
|
||||
setUsers(newUsers);
|
||||
@ -80,7 +79,7 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
setLoading(true)
|
||||
setLoading(true);
|
||||
const actions: number[] = [];
|
||||
const usernames: string[] = [];
|
||||
|
||||
@ -95,8 +94,8 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
.files;
|
||||
|
||||
if (!files) {
|
||||
setLoading(false)
|
||||
return
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
const [evidence] = files;
|
||||
@ -107,20 +106,20 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
bypass: true,
|
||||
filename: evidence.name,
|
||||
filesize: evidence.size,
|
||||
usernames
|
||||
usernames,
|
||||
}),
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
"content-type": "application/json",
|
||||
},
|
||||
method: "POST"
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
if (!submitReq.ok) {
|
||||
setLoading(false)
|
||||
setLoading(false);
|
||||
toast({
|
||||
description: ((await submitReq.json()) as { error: string }).error,
|
||||
status: "error",
|
||||
title: "Failed to submit report"
|
||||
title: "Failed to submit report",
|
||||
});
|
||||
|
||||
return;
|
||||
@ -135,25 +134,25 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
evidence.type ||
|
||||
fileTypes[
|
||||
evidence.name.split(".")[evidence.name.split(".").length - 1]
|
||||
]
|
||||
],
|
||||
},
|
||||
method: "PUT"
|
||||
method: "PUT",
|
||||
});
|
||||
|
||||
if (!fileUpload.ok) {
|
||||
setLoading(false)
|
||||
setLoading(false);
|
||||
await fetch("/api/reports/recall", {
|
||||
body: JSON.stringify({ id }),
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
"content-type": "application/json",
|
||||
},
|
||||
method: "POST"
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
toast({
|
||||
description: "Failed to upload file",
|
||||
status: "error",
|
||||
title: "Error"
|
||||
title: "Error",
|
||||
});
|
||||
|
||||
return;
|
||||
@ -162,18 +161,18 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
await fetch("/api/reports/complete", {
|
||||
body: JSON.stringify({ id }),
|
||||
headers: {
|
||||
"content-type": "application/json"
|
||||
"content-type": "application/json",
|
||||
},
|
||||
method: "POST"
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
toast({
|
||||
description: "User moderated",
|
||||
status: "success",
|
||||
title: "Success"
|
||||
title: "Success",
|
||||
});
|
||||
|
||||
setLoading(false)
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
return (
|
||||
@ -186,7 +185,7 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
<Text>Username(s)</Text>
|
||||
<Input id="username" mb="8px" placeholder="builderman" />
|
||||
<Button
|
||||
onClick={function() {
|
||||
onClick={function () {
|
||||
const user = (
|
||||
document.getElementById("username") as HTMLInputElement
|
||||
).value;
|
||||
@ -204,7 +203,7 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
duration: 5000,
|
||||
isClosable: true,
|
||||
status: "error",
|
||||
title: "Invalid Username"
|
||||
title: "Invalid Username",
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -233,7 +232,7 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
<RadioGroup
|
||||
onChange={(val) =>
|
||||
Object.defineProperty(actionMap, user, {
|
||||
value: parseInt(val)
|
||||
value: parseInt(val),
|
||||
})
|
||||
}
|
||||
>
|
||||
@ -246,12 +245,15 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
</Td>
|
||||
<Td>
|
||||
<Button onClick={() => removeUser(user)} variant="ghost">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
||||
viewBox="0 0 16 16">
|
||||
<path
|
||||
d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6Z" />
|
||||
<path
|
||||
d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1ZM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118ZM2.5 3h11V2h-11v1Z" />
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="16"
|
||||
height="16"
|
||||
fill="currentColor"
|
||||
viewBox="0 0 16 16"
|
||||
>
|
||||
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5Zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6Z" />
|
||||
<path d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1ZM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118ZM2.5 3h11V2h-11v1Z" />
|
||||
</svg>
|
||||
</Button>
|
||||
</Td>
|
||||
@ -286,7 +288,7 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
||||
ml="8px"
|
||||
onClick={async () => await submit()}
|
||||
isLoading={loading}
|
||||
loadingText='Submitting...'
|
||||
loadingText="Submitting..."
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
|
Reference in New Issue
Block a user