Le formatting fixes

This commit is contained in:
regalijan 2023-10-19 16:50:58 -04:00
parent 0a4ad7792d
commit 3155442796
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520
11 changed files with 119 additions and 125 deletions

View File

@ -64,11 +64,11 @@ export default function () {
const pageProps = useLoaderData<typeof loader>();
const { isOpen, onClose, onOpen } = useDisclosure();
const [showSuccess, setShowSuccess] = useState(false);
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
const toast = useToast();
async function submit() {
setLoading(true)
setLoading(true);
const learned = (document.getElementById("learned") as HTMLInputElement)
.value;
const whyBanned = (document.getElementById("whyBanned") as HTMLInputElement)
@ -89,7 +89,7 @@ export default function () {
}).catch(() => {});
if (!submitReq) {
setLoading(false)
setLoading(false);
return toast({
description: "Please check your internet and try again",
duration: 10000,
@ -100,7 +100,7 @@ export default function () {
}
if (!submitReq.ok) {
setLoading(false)
setLoading(false);
return toast({
description: ((await submitReq.json()) as { error: string }).error,
duration: 10000,
@ -111,7 +111,7 @@ export default function () {
}
setShowSuccess(true);
setLoading(false)
setLoading(false);
}
async function toggle(active: boolean) {
@ -239,7 +239,7 @@ export default function () {
<Button
disabled={pageProps.can_appeal}
onClick={async () => await submit()}
loadingText='Submitting'
loadingText="Submitting"
isLoading={loading}
>
Submit

View File

@ -13,7 +13,7 @@ import { useState } from "react";
export default function () {
const [showCookieBox, setShowCookieBox] = useState(false);
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
return (
<Container maxW="container.md">
<Heading pt="36px">Let's get started</Heading>
@ -32,7 +32,7 @@ export default function () {
/>
<Button
onClick={async () => {
setLoading(true)
setLoading(true);
const createTransferReq = await fetch("/api/data-transfers/create", {
body: JSON.stringify({
can_access: !showCookieBox,
@ -47,7 +47,7 @@ export default function () {
});
if (!createTransferReq.ok) {
setLoading(false)
setLoading(false);
useToast()({
description: (
(await createTransferReq.json()) as { error: string }
@ -66,7 +66,7 @@ export default function () {
}}
pt="32px"
isLoading={loading}
loadingText='Processing...'
loadingText="Processing..."
>
Continue
</Button>

View File

@ -42,7 +42,7 @@ export default function () {
const [supportsRequestStreams, setSupportsRequestStreams] = useState(false);
const toast = useToast();
const [uploading, setUploading] = useState(false);
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
const fileTypes: { [k: string]: string } = {
gif: "image/gif",
m4v: "video/x-m4v",
@ -76,7 +76,7 @@ export default function () {
const { logged_in, site_key } = useLoaderData<typeof loader>();
async function submit() {
setLoading(true)
setLoading(true);
const usernames = (
document.getElementById("usernames") as HTMLInputElement
).value
@ -86,7 +86,7 @@ export default function () {
.files;
if (!usernames.length) {
setLoading(false)
setLoading(false);
return toast({
description: "Must provide at least one username",
isClosable: true,
@ -96,7 +96,7 @@ export default function () {
}
if (!files?.length) {
setLoading(false)
setLoading(false);
return toast({
description: "Must attach at least one file",
isClosable: true,
@ -106,7 +106,7 @@ export default function () {
}
if (usernames.length > 20) {
setLoading(false)
setLoading(false);
return toast({
description: "Only up to twenty users can be reported at a time",
isClosable: true,
@ -123,7 +123,7 @@ export default function () {
.item(0) as HTMLInputElement;
if (!tokenElem.value) {
setLoading(false)
setLoading(false);
return toast({
description: "Please complete the captcha and try again",
isClosable: true,
@ -160,7 +160,7 @@ export default function () {
});
if (!submitReq.ok) {
setLoading(false)
setLoading(false);
if (!logged_in) {
try {
// @ts-expect-error
@ -235,7 +235,7 @@ export default function () {
}
if (shouldRecall) {
setLoading(false)
setLoading(false);
await fetch("/api/reports/recall", {
body: JSON.stringify({ id }),
headers: {
@ -264,7 +264,7 @@ export default function () {
});
setShowSuccess(true);
setLoading(false)
setLoading(false);
}
useEffect(() => {
@ -332,7 +332,7 @@ export default function () {
disabled={uploading}
mr="8px"
onClick={async () => await submit()}
loadingText='Submitting'
loadingText="Submitting"
isLoading={loading}
>
Submit

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) {
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 }) {
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 (
@ -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,7 +12,7 @@ import {
Text,
Textarea,
useToast,
VStack
VStack,
} from "@chakra-ui/react";
import { useState } from "react";
@ -22,7 +22,7 @@ export default function(props: {
onClose: () => void;
}) {
const [departments, setDepartments] = useState([] as string[]);
const [loading, setLoading] = useState(false)
const [loading, setLoading] = useState(false);
const toast = useToast();
function reset() {
@ -34,7 +34,7 @@ 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)
@ -42,12 +42,12 @@ export default function(props: {
if (!departments.length) {
toast({
title: 'Validation Error',
description: 'You need to select at least one department',
status: "error"
})
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,

View File

@ -3,7 +3,7 @@ import validateInactivityNotice from "./validate.js";
export async function onRequestDelete(context: RequestContext) {
const kvResult = await context.env.DATA.get(
`inactivity_${context.params.id}`
`inactivity_${context.params.id}`,
);
if (!kvResult) return jsonError("No inactivity notice with that ID", 404);
@ -14,7 +14,7 @@ export async function onRequestDelete(context: RequestContext) {
)
return jsonError(
"You do not have permission to delete this inactivity notice",
403
403,
);
await context.env.DATA.delete(`inactivity_${context.params.id}`);
@ -23,7 +23,7 @@ export async function onRequestDelete(context: RequestContext) {
.run();
return new Response(null, {
status: 204
status: 204,
});
}
@ -37,11 +37,11 @@ export async function onRequestPost(context: RequestContext) {
DM: 1 << 11,
ET: 1 << 4,
FM: 1 << 7,
WM: 1 << 6
WM: 1 << 6,
};
const userAdminDepartments = Object.keys(adminDepartments).filter(
(dept) => context.data.current_user.permissions & adminDepartments[dept]
(dept) => context.data.current_user.permissions & adminDepartments[dept],
);
if (!userAdminDepartments.length)
@ -49,7 +49,7 @@ export async function onRequestPost(context: RequestContext) {
const requestedNotice: { [k: string]: any } | null =
await context.env.DATA.get(`inactivity_${context.params.id as string}`, {
type: "json"
type: "json",
});
if (!requestedNotice)
@ -65,18 +65,18 @@ export async function onRequestPost(context: RequestContext) {
await context.env.DATA.put(
`inactivity_${context.params.id as string}`,
JSON.stringify(requestedNotice),
{ expirationTtl: 63072000 }
{ expirationTtl: 63072000 },
);
return new Response(null, {
status: 204
status: 204,
});
}
export async function onRequestPut(context: RequestContext) {
const kvResult: InactivityNoticeProps | null = await context.env.DATA.get(
`inactivity_${context.params.id}`,
{ type: "json" }
{ type: "json" },
);
if (!kvResult) return jsonError("No inactivity notice with that ID", 404);
@ -84,11 +84,11 @@ export async function onRequestPut(context: RequestContext) {
if (kvResult.user.id !== context.data.current_user.id)
return jsonError(
"You do not have permission to modify this inactivity notice",
403
403,
);
const d1entry = await context.env.D1.prepare(
"SELECT open FROM inactivity_notices WHERE id = ?;"
"SELECT open FROM inactivity_notices WHERE id = ?;",
)
.bind(context.params.id)
.run();
@ -103,7 +103,7 @@ export async function onRequestPut(context: RequestContext) {
end,
reason,
start,
context.data.departments
context.data.departments,
);
if (validationFailureResponse) return validationFailureResponse;
@ -117,11 +117,11 @@ export async function onRequestPut(context: RequestContext) {
`inactivity_${context.params.id}`,
JSON.stringify(kvResult),
{
expirationTtl: 63072000
}
expirationTtl: 63072000,
},
);
return new Response(null, {
status: 204
status: 204,
});
}