From 31554427963ced179f9b7cd9a7a7bcbd02f1eedb Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:58 -0400 Subject: [PATCH] Le formatting fixes --- app/routes/appeals.tsx | 12 ++--- app/routes/data-transfer/start.tsx | 8 ++-- app/routes/report.tsx | 20 ++++----- components/AppealCard.tsx | 12 ++--- components/GameAppealCard.tsx | 8 ++-- components/InactivityNoticeCard.tsx | 30 ++++++------- components/NewGameBan.tsx | 70 +++++++++++++++-------------- components/NewInactivityNotice.tsx | 36 +++++++-------- components/ReportCard.tsx | 10 ++--- components/Success.tsx | 8 +--- functions/api/inactivity/[id].ts | 30 ++++++------- 11 files changed, 119 insertions(+), 125 deletions(-) diff --git a/app/routes/appeals.tsx b/app/routes/appeals.tsx index 09ffb3c..83fc5a3 100644 --- a/app/routes/appeals.tsx +++ b/app/routes/appeals.tsx @@ -64,11 +64,11 @@ export default function () { const pageProps = useLoaderData(); 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 () { diff --git a/app/routes/report.tsx b/app/routes/report.tsx index 3320ef1..7eea0ca 100644 --- a/app/routes/report.tsx +++ b/app/routes/report.tsx @@ -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(); 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 diff --git a/components/AppealCard.tsx b/components/AppealCard.tsx index de16e36..f7d10ef 100644 --- a/components/AppealCard.tsx +++ b/components/AppealCard.tsx @@ -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) { diff --git a/components/GameAppealCard.tsx b/components/GameAppealCard.tsx index 72af496..a30759b 100644 --- a/components/GameAppealCard.tsx +++ b/components/GameAppealCard.tsx @@ -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 { - 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 diff --git a/components/InactivityNoticeCard.tsx b/components/InactivityNoticeCard.tsx index 49a0010..79c4c29 100644 --- a/components/InactivityNoticeCard.tsx +++ b/components/InactivityNoticeCard.tsx @@ -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 = () => ( - + ); const Denied = () => ( - + ); @@ -109,7 +107,7 @@ export default function(props: InactivityNoticeProps) { colorScheme="red" onClick={async () => await makeDecision(false)} isLoading={loading} - loadingText='Processing...' + loadingText="Processing..." > Deny @@ -118,7 +116,7 @@ export default function(props: InactivityNoticeProps) { ml="8px" onClick={async () => await makeDecision(true)} isLoading={loading} - loadingText='Processing...' + loadingText="Processing..." > Accept diff --git a/components/NewGameBan.tsx b/components/NewGameBan.tsx index c217cc7..4ab9bea 100644 --- a/components/NewGameBan.tsx +++ b/components/NewGameBan.tsx @@ -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 }) { Username(s) @@ -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 diff --git a/components/NewInactivityNotice.tsx b/components/NewInactivityNotice.tsx index c26466f..b252c16 100644 --- a/components/NewInactivityNotice.tsx +++ b/components/NewInactivityNotice.tsx @@ -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 diff --git a/components/ReportCard.tsx b/components/ReportCard.tsx index 29ee037..b3a15e0 100644 --- a/components/ReportCard.tsx +++ b/components/ReportCard.tsx @@ -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 diff --git a/components/Success.tsx b/components/Success.tsx index 3d68d62..174abc9 100644 --- a/components/Success.tsx +++ b/components/Success.tsx @@ -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, diff --git a/functions/api/inactivity/[id].ts b/functions/api/inactivity/[id].ts index c1963e5..089e73b 100644 --- a/functions/api/inactivity/[id].ts +++ b/functions/api/inactivity/[id].ts @@ -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, }); }