Le formatting fixes
This commit is contained in:
parent
0a4ad7792d
commit
3155442796
@ -64,11 +64,11 @@ export default function () {
|
|||||||
const pageProps = useLoaderData<typeof loader>();
|
const pageProps = useLoaderData<typeof loader>();
|
||||||
const { isOpen, onClose, onOpen } = useDisclosure();
|
const { isOpen, onClose, onOpen } = useDisclosure();
|
||||||
const [showSuccess, setShowSuccess] = useState(false);
|
const [showSuccess, setShowSuccess] = useState(false);
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const learned = (document.getElementById("learned") as HTMLInputElement)
|
const learned = (document.getElementById("learned") as HTMLInputElement)
|
||||||
.value;
|
.value;
|
||||||
const whyBanned = (document.getElementById("whyBanned") as HTMLInputElement)
|
const whyBanned = (document.getElementById("whyBanned") as HTMLInputElement)
|
||||||
@ -89,7 +89,7 @@ export default function () {
|
|||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
|
|
||||||
if (!submitReq) {
|
if (!submitReq) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
return toast({
|
return toast({
|
||||||
description: "Please check your internet and try again",
|
description: "Please check your internet and try again",
|
||||||
duration: 10000,
|
duration: 10000,
|
||||||
@ -100,7 +100,7 @@ export default function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!submitReq.ok) {
|
if (!submitReq.ok) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
return toast({
|
return toast({
|
||||||
description: ((await submitReq.json()) as { error: string }).error,
|
description: ((await submitReq.json()) as { error: string }).error,
|
||||||
duration: 10000,
|
duration: 10000,
|
||||||
@ -111,7 +111,7 @@ export default function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setShowSuccess(true);
|
setShowSuccess(true);
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toggle(active: boolean) {
|
async function toggle(active: boolean) {
|
||||||
@ -239,7 +239,7 @@ export default function () {
|
|||||||
<Button
|
<Button
|
||||||
disabled={pageProps.can_appeal}
|
disabled={pageProps.can_appeal}
|
||||||
onClick={async () => await submit()}
|
onClick={async () => await submit()}
|
||||||
loadingText='Submitting'
|
loadingText="Submitting"
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
|
@ -13,7 +13,7 @@ import { useState } from "react";
|
|||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const [showCookieBox, setShowCookieBox] = useState(false);
|
const [showCookieBox, setShowCookieBox] = useState(false);
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
return (
|
return (
|
||||||
<Container maxW="container.md">
|
<Container maxW="container.md">
|
||||||
<Heading pt="36px">Let's get started</Heading>
|
<Heading pt="36px">Let's get started</Heading>
|
||||||
@ -32,7 +32,7 @@ export default function () {
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const createTransferReq = await fetch("/api/data-transfers/create", {
|
const createTransferReq = await fetch("/api/data-transfers/create", {
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
can_access: !showCookieBox,
|
can_access: !showCookieBox,
|
||||||
@ -47,7 +47,7 @@ export default function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!createTransferReq.ok) {
|
if (!createTransferReq.ok) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
useToast()({
|
useToast()({
|
||||||
description: (
|
description: (
|
||||||
(await createTransferReq.json()) as { error: string }
|
(await createTransferReq.json()) as { error: string }
|
||||||
@ -66,7 +66,7 @@ export default function () {
|
|||||||
}}
|
}}
|
||||||
pt="32px"
|
pt="32px"
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
loadingText='Processing...'
|
loadingText="Processing..."
|
||||||
>
|
>
|
||||||
Continue
|
Continue
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -42,7 +42,7 @@ export default function () {
|
|||||||
const [supportsRequestStreams, setSupportsRequestStreams] = useState(false);
|
const [supportsRequestStreams, setSupportsRequestStreams] = useState(false);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const [uploading, setUploading] = useState(false);
|
const [uploading, setUploading] = useState(false);
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
const fileTypes: { [k: string]: string } = {
|
const fileTypes: { [k: string]: string } = {
|
||||||
gif: "image/gif",
|
gif: "image/gif",
|
||||||
m4v: "video/x-m4v",
|
m4v: "video/x-m4v",
|
||||||
@ -76,7 +76,7 @@ export default function () {
|
|||||||
const { logged_in, site_key } = useLoaderData<typeof loader>();
|
const { logged_in, site_key } = useLoaderData<typeof loader>();
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const usernames = (
|
const usernames = (
|
||||||
document.getElementById("usernames") as HTMLInputElement
|
document.getElementById("usernames") as HTMLInputElement
|
||||||
).value
|
).value
|
||||||
@ -86,7 +86,7 @@ export default function () {
|
|||||||
.files;
|
.files;
|
||||||
|
|
||||||
if (!usernames.length) {
|
if (!usernames.length) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
return toast({
|
return toast({
|
||||||
description: "Must provide at least one username",
|
description: "Must provide at least one username",
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
@ -96,7 +96,7 @@ export default function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!files?.length) {
|
if (!files?.length) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
return toast({
|
return toast({
|
||||||
description: "Must attach at least one file",
|
description: "Must attach at least one file",
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
@ -106,7 +106,7 @@ export default function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (usernames.length > 20) {
|
if (usernames.length > 20) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
return toast({
|
return toast({
|
||||||
description: "Only up to twenty users can be reported at a time",
|
description: "Only up to twenty users can be reported at a time",
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
@ -123,7 +123,7 @@ export default function () {
|
|||||||
.item(0) as HTMLInputElement;
|
.item(0) as HTMLInputElement;
|
||||||
|
|
||||||
if (!tokenElem.value) {
|
if (!tokenElem.value) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
return toast({
|
return toast({
|
||||||
description: "Please complete the captcha and try again",
|
description: "Please complete the captcha and try again",
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
@ -160,7 +160,7 @@ export default function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!submitReq.ok) {
|
if (!submitReq.ok) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
if (!logged_in) {
|
if (!logged_in) {
|
||||||
try {
|
try {
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
@ -235,7 +235,7 @@ export default function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (shouldRecall) {
|
if (shouldRecall) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
await fetch("/api/reports/recall", {
|
await fetch("/api/reports/recall", {
|
||||||
body: JSON.stringify({ id }),
|
body: JSON.stringify({ id }),
|
||||||
headers: {
|
headers: {
|
||||||
@ -264,7 +264,7 @@ export default function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setShowSuccess(true);
|
setShowSuccess(true);
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -332,7 +332,7 @@ export default function () {
|
|||||||
disabled={uploading}
|
disabled={uploading}
|
||||||
mr="8px"
|
mr="8px"
|
||||||
onClick={async () => await submit()}
|
onClick={async () => await submit()}
|
||||||
loadingText='Submitting'
|
loadingText="Submitting"
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
|
@ -27,7 +27,7 @@ export default function (props: AppealCardProps) {
|
|||||||
);
|
);
|
||||||
const [action, setAction] = useState("");
|
const [action, setAction] = useState("");
|
||||||
const [feedback, setFeedback] = useState("");
|
const [feedback, setFeedback] = useState("");
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -42,7 +42,7 @@ export default function (props: AppealCardProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function takeAction(action: string) {
|
async function takeAction(action: string) {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const actionReq = await fetch(`/api/appeals/${props.id}/${action}`, {
|
const actionReq = await fetch(`/api/appeals/${props.id}/${action}`, {
|
||||||
body: feedback ? JSON.stringify({ feedback }) : "{}",
|
body: feedback ? JSON.stringify({ feedback }) : "{}",
|
||||||
headers: {
|
headers: {
|
||||||
@ -52,7 +52,7 @@ export default function (props: AppealCardProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (actionReq.ok) {
|
if (actionReq.ok) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
toast({
|
toast({
|
||||||
description: `Appeal ${action === "accept" ? "accepted" : "denied"}`,
|
description: `Appeal ${action === "accept" ? "accepted" : "denied"}`,
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
@ -62,7 +62,7 @@ export default function (props: AppealCardProps) {
|
|||||||
|
|
||||||
document.getElementById(`appeal_${props.id}`)?.remove();
|
document.getElementById(`appeal_${props.id}`)?.remove();
|
||||||
} else {
|
} else {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
toast({
|
toast({
|
||||||
description: ((await actionReq.json()) as { error: string }).error,
|
description: ((await actionReq.json()) as { error: string }).error,
|
||||||
duration: 10000,
|
duration: 10000,
|
||||||
@ -72,7 +72,7 @@ export default function (props: AppealCardProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -92,7 +92,7 @@ export default function (props: AppealCardProps) {
|
|||||||
<Button
|
<Button
|
||||||
onClick={async () => await takeAction(action.toLowerCase())}
|
onClick={async () => await takeAction(action.toLowerCase())}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
loadingText='Submitting...'
|
loadingText="Submitting..."
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -21,9 +21,9 @@ import {
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function (props: GameAppealProps) {
|
export default function (props: GameAppealProps) {
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
async function performAction(action: "accept" | "deny"): Promise<void> {
|
async function performAction(action: "accept" | "deny"): Promise<void> {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const statsReduction = parseInt(
|
const statsReduction = parseInt(
|
||||||
(document.getElementById("reductPercentage") as HTMLInputElement).value,
|
(document.getElementById("reductPercentage") as HTMLInputElement).value,
|
||||||
);
|
);
|
||||||
@ -55,7 +55,7 @@ export default function (props: GameAppealProps) {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { isOpen, onClose, onOpen } = useDisclosure();
|
const { isOpen, onClose, onOpen } = useDisclosure();
|
||||||
@ -114,7 +114,7 @@ export default function (props: GameAppealProps) {
|
|||||||
ml="8px"
|
ml="8px"
|
||||||
onClick={async () => await performAction("accept")}
|
onClick={async () => await performAction("accept")}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
loadingText='Submitting...'
|
loadingText="Submitting..."
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -11,31 +11,31 @@ import {
|
|||||||
StackDivider,
|
StackDivider,
|
||||||
Text,
|
Text,
|
||||||
UnorderedList,
|
UnorderedList,
|
||||||
useToast
|
useToast,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function(props: InactivityNoticeProps) {
|
export default function (props: InactivityNoticeProps) {
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
async function makeDecision(accepted: boolean) {
|
async function makeDecision(accepted: boolean) {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const decisionReq = await fetch(`/api/inactivity/${props.id}`, {
|
const decisionReq = await fetch(`/api/inactivity/${props.id}`, {
|
||||||
body: JSON.stringify({ accepted }),
|
body: JSON.stringify({ accepted }),
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json",
|
||||||
},
|
},
|
||||||
method: "POST"
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!decisionReq.ok) {
|
if (!decisionReq.ok) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
toast({
|
toast({
|
||||||
description: ((await decisionReq.json()) as { error: string }).error,
|
description: ((await decisionReq.json()) as { error: string }).error,
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "Oops"
|
title: "Oops",
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -45,24 +45,22 @@ export default function(props: InactivityNoticeProps) {
|
|||||||
description: `Inactivity notice ${accepted ? "accepted" : "denied"}.`,
|
description: `Inactivity notice ${accepted ? "accepted" : "denied"}.`,
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: "success",
|
status: "success",
|
||||||
title: "Success"
|
title: "Success",
|
||||||
});
|
});
|
||||||
|
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Approved = () => (
|
const Approved = () => (
|
||||||
<svg fill="currentColor" height="16" viewBox="0 0 16 16" width="16">
|
<svg fill="currentColor" height="16" viewBox="0 0 16 16" width="16">
|
||||||
<path
|
<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" />
|
||||||
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>
|
</svg>
|
||||||
);
|
);
|
||||||
|
|
||||||
const Denied = () => (
|
const Denied = () => (
|
||||||
<svg fill="currentColor" height="16" viewBox="0 0 16 16" width="16">
|
<svg fill="currentColor" height="16" viewBox="0 0 16 16" width="16">
|
||||||
<path
|
<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" />
|
||||||
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>
|
</svg>
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -109,7 +107,7 @@ export default function(props: InactivityNoticeProps) {
|
|||||||
colorScheme="red"
|
colorScheme="red"
|
||||||
onClick={async () => await makeDecision(false)}
|
onClick={async () => await makeDecision(false)}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
loadingText='Processing...'
|
loadingText="Processing..."
|
||||||
>
|
>
|
||||||
Deny
|
Deny
|
||||||
</Button>
|
</Button>
|
||||||
@ -118,7 +116,7 @@ export default function(props: InactivityNoticeProps) {
|
|||||||
ml="8px"
|
ml="8px"
|
||||||
onClick={async () => await makeDecision(true)}
|
onClick={async () => await makeDecision(true)}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
loadingText='Processing...'
|
loadingText="Processing..."
|
||||||
>
|
>
|
||||||
Accept
|
Accept
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -20,14 +20,14 @@ 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";
|
||||||
|
|
||||||
export default function(props: { isOpen: boolean; onClose: () => void }) {
|
export default function (props: { isOpen: boolean; onClose: () => void }) {
|
||||||
const actionMap: { [k: string]: number } = {};
|
const actionMap: { [k: string]: number } = {};
|
||||||
const [users, setUsers] = useState([] as string[]);
|
const [users, setUsers] = useState([] as string[]);
|
||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const fileTypes: { [k: string]: string } = {
|
const fileTypes: { [k: string]: string } = {
|
||||||
gif: "image/gif",
|
gif: "image/gif",
|
||||||
@ -43,15 +43,14 @@ 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) {
|
||||||
(document.getElementById("username") as HTMLInputElement).value = "";
|
(document.getElementById("username") as HTMLInputElement).value = "";
|
||||||
const newUsers = [...users];
|
const newUsers = [...users];
|
||||||
|
|
||||||
if (newUsers.includes(user))
|
if (newUsers.includes(user)) return;
|
||||||
return;
|
|
||||||
|
|
||||||
newUsers.push(user);
|
newUsers.push(user);
|
||||||
setUsers(newUsers);
|
setUsers(newUsers);
|
||||||
@ -80,7 +79,7 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const actions: number[] = [];
|
const actions: number[] = [];
|
||||||
const usernames: string[] = [];
|
const usernames: string[] = [];
|
||||||
|
|
||||||
@ -95,8 +94,8 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
.files;
|
.files;
|
||||||
|
|
||||||
if (!files) {
|
if (!files) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [evidence] = files;
|
const [evidence] = files;
|
||||||
@ -107,20 +106,20 @@ 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) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
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;
|
||||||
@ -135,25 +134,25 @@ 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) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
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;
|
||||||
@ -162,18 +161,18 @@ 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",
|
||||||
});
|
});
|
||||||
|
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -186,7 +185,7 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
<Text>Username(s)</Text>
|
<Text>Username(s)</Text>
|
||||||
<Input id="username" mb="8px" placeholder="builderman" />
|
<Input id="username" mb="8px" placeholder="builderman" />
|
||||||
<Button
|
<Button
|
||||||
onClick={function() {
|
onClick={function () {
|
||||||
const user = (
|
const user = (
|
||||||
document.getElementById("username") as HTMLInputElement
|
document.getElementById("username") as HTMLInputElement
|
||||||
).value;
|
).value;
|
||||||
@ -204,7 +203,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;
|
||||||
}
|
}
|
||||||
@ -233,7 +232,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),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@ -246,12 +245,15 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
</Td>
|
</Td>
|
||||||
<Td>
|
<Td>
|
||||||
<Button onClick={() => removeUser(user)} variant="ghost">
|
<Button onClick={() => removeUser(user)} variant="ghost">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
|
<svg
|
||||||
viewBox="0 0 16 16">
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<path
|
width="16"
|
||||||
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" />
|
height="16"
|
||||||
<path
|
fill="currentColor"
|
||||||
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" />
|
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>
|
</svg>
|
||||||
</Button>
|
</Button>
|
||||||
</Td>
|
</Td>
|
||||||
@ -286,7 +288,7 @@ export default function(props: { isOpen: boolean; onClose: () => void }) {
|
|||||||
ml="8px"
|
ml="8px"
|
||||||
onClick={async () => await submit()}
|
onClick={async () => await submit()}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
loadingText='Submitting...'
|
loadingText="Submitting..."
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -12,17 +12,17 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Textarea,
|
Textarea,
|
||||||
useToast,
|
useToast,
|
||||||
VStack
|
VStack,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function(props: {
|
export default function (props: {
|
||||||
departments: string[];
|
departments: string[];
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}) {
|
}) {
|
||||||
const [departments, setDepartments] = useState([] as string[]);
|
const [departments, setDepartments] = useState([] as string[]);
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
@ -34,20 +34,20 @@ export default function(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const start = (document.getElementById("start") as HTMLInputElement).value;
|
const start = (document.getElementById("start") as HTMLInputElement).value;
|
||||||
const end = (document.getElementById("start") as HTMLInputElement).value;
|
const end = (document.getElementById("start") as HTMLInputElement).value;
|
||||||
const reason = (document.getElementById("reason") as HTMLTextAreaElement)
|
const reason = (document.getElementById("reason") as HTMLTextAreaElement)
|
||||||
.value;
|
.value;
|
||||||
|
|
||||||
if (!departments.length) {
|
if (!departments.length) {
|
||||||
toast({
|
toast({
|
||||||
title: 'Validation Error',
|
title: "Validation Error",
|
||||||
description: 'You need to select at least one department',
|
description: "You need to select at least one department",
|
||||||
status: "error"
|
status: "error",
|
||||||
})
|
});
|
||||||
|
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,22 +56,22 @@ export default function(props: {
|
|||||||
departments,
|
departments,
|
||||||
end,
|
end,
|
||||||
reason,
|
reason,
|
||||||
start
|
start,
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json",
|
||||||
},
|
},
|
||||||
method: "POST"
|
method: "POST",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!inactivityPost.ok) {
|
if (!inactivityPost.ok) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
toast({
|
toast({
|
||||||
description: ((await inactivityPost.json()) as { error: string }).error,
|
description: ((await inactivityPost.json()) as { error: string }).error,
|
||||||
duration: 10000,
|
duration: 10000,
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "Error"
|
title: "Error",
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -82,10 +82,10 @@ export default function(props: {
|
|||||||
duration: 10000,
|
duration: 10000,
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: "success",
|
status: "success",
|
||||||
title: "Success"
|
title: "Success",
|
||||||
});
|
});
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
props.onClose();
|
props.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ export default function(props: {
|
|||||||
ml="8px"
|
ml="8px"
|
||||||
onClick={async () => await submit()}
|
onClick={async () => await submit()}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
loadingText='Submitting...'
|
loadingText="Submitting..."
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -18,7 +18,7 @@ import { useState } from "react";
|
|||||||
|
|
||||||
export default function (props: ReportCardProps) {
|
export default function (props: ReportCardProps) {
|
||||||
const [attachmentIdx, setAttachmentIdx] = useState(0);
|
const [attachmentIdx, setAttachmentIdx] = useState(0);
|
||||||
const [loading, setLoading] = useState(false)
|
const [loading, setLoading] = useState(false);
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const targetMap: { [k: number]: string } = {};
|
const targetMap: { [k: number]: string } = {};
|
||||||
const [attachmentsReady, setAttachmentReady] = useState(
|
const [attachmentsReady, setAttachmentReady] = useState(
|
||||||
@ -44,7 +44,7 @@ export default function (props: ReportCardProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function submitActions() {
|
async function submitActions() {
|
||||||
setLoading(true)
|
setLoading(true);
|
||||||
const submitReq = await fetch(`/api/reports/${props.id}/action`, {
|
const submitReq = await fetch(`/api/reports/${props.id}/action`, {
|
||||||
body: JSON.stringify(actionMap),
|
body: JSON.stringify(actionMap),
|
||||||
headers: {
|
headers: {
|
||||||
@ -54,7 +54,7 @@ export default function (props: ReportCardProps) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!submitReq.ok) {
|
if (!submitReq.ok) {
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
toast({
|
toast({
|
||||||
description: ((await submitReq.json()) as { error: string }).error,
|
description: ((await submitReq.json()) as { error: string }).error,
|
||||||
status: "error",
|
status: "error",
|
||||||
@ -69,7 +69,7 @@ export default function (props: ReportCardProps) {
|
|||||||
status: "success",
|
status: "success",
|
||||||
title: "Success",
|
title: "Success",
|
||||||
});
|
});
|
||||||
setLoading(false)
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -192,7 +192,7 @@ export default function (props: ReportCardProps) {
|
|||||||
colorScheme="blue"
|
colorScheme="blue"
|
||||||
onClick={async () => await submitActions()}
|
onClick={async () => await submitActions()}
|
||||||
isLoading={loading}
|
isLoading={loading}
|
||||||
loadingText='Submitting...'
|
loadingText="Submitting..."
|
||||||
>
|
>
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
import {
|
import { Container, Flex, Heading, Spacer, Text } from "@chakra-ui/react";
|
||||||
Container,
|
|
||||||
Flex,
|
|
||||||
Heading,
|
|
||||||
Spacer,
|
|
||||||
Text,
|
|
||||||
} from "@chakra-ui/react";
|
|
||||||
|
|
||||||
export default function ({
|
export default function ({
|
||||||
heading,
|
heading,
|
||||||
|
@ -3,7 +3,7 @@ import validateInactivityNotice from "./validate.js";
|
|||||||
|
|
||||||
export async function onRequestDelete(context: RequestContext) {
|
export async function onRequestDelete(context: RequestContext) {
|
||||||
const kvResult = await context.env.DATA.get(
|
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);
|
if (!kvResult) return jsonError("No inactivity notice with that ID", 404);
|
||||||
@ -14,7 +14,7 @@ export async function onRequestDelete(context: RequestContext) {
|
|||||||
)
|
)
|
||||||
return jsonError(
|
return jsonError(
|
||||||
"You do not have permission to delete this inactivity notice",
|
"You do not have permission to delete this inactivity notice",
|
||||||
403
|
403,
|
||||||
);
|
);
|
||||||
|
|
||||||
await context.env.DATA.delete(`inactivity_${context.params.id}`);
|
await context.env.DATA.delete(`inactivity_${context.params.id}`);
|
||||||
@ -23,7 +23,7 @@ export async function onRequestDelete(context: RequestContext) {
|
|||||||
.run();
|
.run();
|
||||||
|
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
status: 204
|
status: 204,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,11 +37,11 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
DM: 1 << 11,
|
DM: 1 << 11,
|
||||||
ET: 1 << 4,
|
ET: 1 << 4,
|
||||||
FM: 1 << 7,
|
FM: 1 << 7,
|
||||||
WM: 1 << 6
|
WM: 1 << 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
const userAdminDepartments = Object.keys(adminDepartments).filter(
|
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)
|
if (!userAdminDepartments.length)
|
||||||
@ -49,7 +49,7 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
|
|
||||||
const requestedNotice: { [k: string]: any } | null =
|
const requestedNotice: { [k: string]: any } | null =
|
||||||
await context.env.DATA.get(`inactivity_${context.params.id as string}`, {
|
await context.env.DATA.get(`inactivity_${context.params.id as string}`, {
|
||||||
type: "json"
|
type: "json",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!requestedNotice)
|
if (!requestedNotice)
|
||||||
@ -65,18 +65,18 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
await context.env.DATA.put(
|
await context.env.DATA.put(
|
||||||
`inactivity_${context.params.id as string}`,
|
`inactivity_${context.params.id as string}`,
|
||||||
JSON.stringify(requestedNotice),
|
JSON.stringify(requestedNotice),
|
||||||
{ expirationTtl: 63072000 }
|
{ expirationTtl: 63072000 },
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
status: 204
|
status: 204,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function onRequestPut(context: RequestContext) {
|
export async function onRequestPut(context: RequestContext) {
|
||||||
const kvResult: InactivityNoticeProps | null = await context.env.DATA.get(
|
const kvResult: InactivityNoticeProps | null = await context.env.DATA.get(
|
||||||
`inactivity_${context.params.id}`,
|
`inactivity_${context.params.id}`,
|
||||||
{ type: "json" }
|
{ type: "json" },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!kvResult) return jsonError("No inactivity notice with that ID", 404);
|
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)
|
if (kvResult.user.id !== context.data.current_user.id)
|
||||||
return jsonError(
|
return jsonError(
|
||||||
"You do not have permission to modify this inactivity notice",
|
"You do not have permission to modify this inactivity notice",
|
||||||
403
|
403,
|
||||||
);
|
);
|
||||||
|
|
||||||
const d1entry = await context.env.D1.prepare(
|
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)
|
.bind(context.params.id)
|
||||||
.run();
|
.run();
|
||||||
@ -103,7 +103,7 @@ export async function onRequestPut(context: RequestContext) {
|
|||||||
end,
|
end,
|
||||||
reason,
|
reason,
|
||||||
start,
|
start,
|
||||||
context.data.departments
|
context.data.departments,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (validationFailureResponse) return validationFailureResponse;
|
if (validationFailureResponse) return validationFailureResponse;
|
||||||
@ -117,11 +117,11 @@ export async function onRequestPut(context: RequestContext) {
|
|||||||
`inactivity_${context.params.id}`,
|
`inactivity_${context.params.id}`,
|
||||||
JSON.stringify(kvResult),
|
JSON.stringify(kvResult),
|
||||||
{
|
{
|
||||||
expirationTtl: 63072000
|
expirationTtl: 63072000,
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
status: 204
|
status: 204,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user