Le formatting fixes

This commit is contained in:
2023-10-19 16:50:58 -04:00
parent 0a4ad7792d
commit 3155442796
11 changed files with 119 additions and 125 deletions

View File

@ -27,7 +27,7 @@ export default function (props: AppealCardProps) {
);
const [action, setAction] = useState("");
const [feedback, setFeedback] = useState("");
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
const toast = useToast();
useEffect(() => {
@ -42,7 +42,7 @@ export default function (props: AppealCardProps) {
}
async function takeAction(action: string) {
setLoading(true)
setLoading(true);
const actionReq = await fetch(`/api/appeals/${props.id}/${action}`, {
body: feedback ? JSON.stringify({ feedback }) : "{}",
headers: {
@ -52,7 +52,7 @@ export default function (props: AppealCardProps) {
});
if (actionReq.ok) {
setLoading(false)
setLoading(false);
toast({
description: `Appeal ${action === "accept" ? "accepted" : "denied"}`,
duration: 5000,
@ -62,7 +62,7 @@ export default function (props: AppealCardProps) {
document.getElementById(`appeal_${props.id}`)?.remove();
} else {
setLoading(false)
setLoading(false);
toast({
description: ((await actionReq.json()) as { error: string }).error,
duration: 10000,
@ -72,7 +72,7 @@ export default function (props: AppealCardProps) {
}
onClose();
setLoading(false)
setLoading(false);
}
return (
@ -92,7 +92,7 @@ export default function (props: AppealCardProps) {
<Button
onClick={async () => await takeAction(action.toLowerCase())}
isLoading={loading}
loadingText='Submitting...'
loadingText="Submitting..."
>
Submit
</Button>

View File

@ -21,9 +21,9 @@ import {
import { useState } from "react";
export default function (props: GameAppealProps) {
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
async function performAction(action: "accept" | "deny"): Promise<void> {
setLoading(true)
setLoading(true);
const statsReduction = parseInt(
(document.getElementById("reductPercentage") as HTMLInputElement).value,
);
@ -55,7 +55,7 @@ export default function (props: GameAppealProps) {
},
);
setLoading(false)
setLoading(false);
}
const { isOpen, onClose, onOpen } = useDisclosure();
@ -114,7 +114,7 @@ export default function (props: GameAppealProps) {
ml="8px"
onClick={async () => await performAction("accept")}
isLoading={loading}
loadingText='Submitting...'
loadingText="Submitting..."
>
Submit
</Button>

View File

@ -11,31 +11,31 @@ import {
StackDivider,
Text,
UnorderedList,
useToast
useToast,
} from "@chakra-ui/react";
import { useState } from "react";
export default function(props: InactivityNoticeProps) {
export default function (props: InactivityNoticeProps) {
const toast = useToast();
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
async function makeDecision(accepted: boolean) {
setLoading(true)
setLoading(true);
const decisionReq = await fetch(`/api/inactivity/${props.id}`, {
body: JSON.stringify({ accepted }),
headers: {
"content-type": "application/json"
"content-type": "application/json",
},
method: "POST"
method: "POST",
});
if (!decisionReq.ok) {
setLoading(false)
setLoading(false);
toast({
description: ((await decisionReq.json()) as { error: string }).error,
isClosable: true,
status: "error",
title: "Oops"
title: "Oops",
});
return;
@ -45,24 +45,22 @@ export default function(props: InactivityNoticeProps) {
description: `Inactivity notice ${accepted ? "accepted" : "denied"}.`,
isClosable: true,
status: "success",
title: "Success"
title: "Success",
});
setLoading(false)
setLoading(false);
location.reload();
}
const Approved = () => (
<svg fill="currentColor" height="16" viewBox="0 0 16 16" width="16">
<path
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
</svg>
);
const Denied = () => (
<svg fill="currentColor" height="16" viewBox="0 0 16 16" width="16">
<path
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z" />
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM5.354 4.646a.5.5 0 1 0-.708.708L7.293 8l-2.647 2.646a.5.5 0 0 0 .708.708L8 8.707l2.646 2.647a.5.5 0 0 0 .708-.708L8.707 8l2.647-2.646a.5.5 0 0 0-.708-.708L8 7.293 5.354 4.646z" />
</svg>
);
@ -109,7 +107,7 @@ export default function(props: InactivityNoticeProps) {
colorScheme="red"
onClick={async () => await makeDecision(false)}
isLoading={loading}
loadingText='Processing...'
loadingText="Processing..."
>
Deny
</Button>
@ -118,7 +116,7 @@ export default function(props: InactivityNoticeProps) {
ml="8px"
onClick={async () => await makeDecision(true)}
isLoading={loading}
loadingText='Processing...'
loadingText="Processing..."
>
Accept
</Button>

View File

@ -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>

View File

@ -12,17 +12,17 @@ import {
Text,
Textarea,
useToast,
VStack
VStack,
} from "@chakra-ui/react";
import { useState } from "react";
export default function(props: {
export default function (props: {
departments: string[];
isOpen: boolean;
onClose: () => void;
}) {
const [departments, setDepartments] = useState([] as string[]);
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
const toast = useToast();
function reset() {
@ -34,20 +34,20 @@ export default function(props: {
}
async function submit() {
setLoading(true)
setLoading(true);
const start = (document.getElementById("start") as HTMLInputElement).value;
const end = (document.getElementById("start") as HTMLInputElement).value;
const reason = (document.getElementById("reason") as HTMLTextAreaElement)
.value;
if (!departments.length) {
toast({
title: 'Validation Error',
description: 'You need to select at least one department',
status: "error"
})
toast({
title: "Validation Error",
description: "You need to select at least one department",
status: "error",
});
setLoading(false)
setLoading(false);
return;
}
@ -56,22 +56,22 @@ export default function(props: {
departments,
end,
reason,
start
start,
}),
headers: {
"content-type": "application/json"
"content-type": "application/json",
},
method: "POST"
method: "POST",
});
if (!inactivityPost.ok) {
setLoading(false)
setLoading(false);
toast({
description: ((await inactivityPost.json()) as { error: string }).error,
duration: 10000,
isClosable: true,
status: "error",
title: "Error"
title: "Error",
});
return;
@ -82,10 +82,10 @@ export default function(props: {
duration: 10000,
isClosable: true,
status: "success",
title: "Success"
title: "Success",
});
setLoading(true)
setLoading(true);
props.onClose();
}
@ -129,7 +129,7 @@ export default function(props: {
ml="8px"
onClick={async () => await submit()}
isLoading={loading}
loadingText='Submitting...'
loadingText="Submitting..."
>
Submit
</Button>

View File

@ -18,7 +18,7 @@ import { useState } from "react";
export default function (props: ReportCardProps) {
const [attachmentIdx, setAttachmentIdx] = useState(0);
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
const toast = useToast();
const targetMap: { [k: number]: string } = {};
const [attachmentsReady, setAttachmentReady] = useState(
@ -44,7 +44,7 @@ export default function (props: ReportCardProps) {
}
async function submitActions() {
setLoading(true)
setLoading(true);
const submitReq = await fetch(`/api/reports/${props.id}/action`, {
body: JSON.stringify(actionMap),
headers: {
@ -54,7 +54,7 @@ export default function (props: ReportCardProps) {
});
if (!submitReq.ok) {
setLoading(false)
setLoading(false);
toast({
description: ((await submitReq.json()) as { error: string }).error,
status: "error",
@ -69,7 +69,7 @@ export default function (props: ReportCardProps) {
status: "success",
title: "Success",
});
setLoading(false)
setLoading(false);
}
return (
@ -192,7 +192,7 @@ export default function (props: ReportCardProps) {
colorScheme="blue"
onClick={async () => await submitActions()}
isLoading={loading}
loadingText='Submitting...'
loadingText="Submitting..."
>
Submit
</Button>

View File

@ -1,10 +1,4 @@
import {
Container,
Flex,
Heading,
Spacer,
Text,
} from "@chakra-ui/react";
import { Container, Flex, Heading, Spacer, Text } from "@chakra-ui/react";
export default function ({
heading,