From 91a2f2ea5c226bec7fae1e1d81a919cfc70eca07 Mon Sep 17 00:00:00 2001 From: Regalijan Date: Mon, 30 Oct 2023 12:16:47 -0400 Subject: [PATCH] Create new appeal ban modal --- components/NewAppealBan.tsx | 87 +++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 components/NewAppealBan.tsx diff --git a/components/NewAppealBan.tsx b/components/NewAppealBan.tsx new file mode 100644 index 0000000..fb69e59 --- /dev/null +++ b/components/NewAppealBan.tsx @@ -0,0 +1,87 @@ +import { + Button, + Input, + Modal, + ModalBody, + ModalCloseButton, + ModalContent, + ModalFooter, + ModalHeader, + ModalOverlay, + Text, + useToast, +} from "@chakra-ui/react"; +import { useState } from "react"; + +export default function (props: { isOpen: boolean; onClose: () => void }) { + const [userID, setUserID] = useState(""); + const [loading, setLoading] = useState(false); + const toast = useToast(); + + async function submitBan() { + const submitResp = await fetch(`/appeals/${userID}/ban`, { + body: "{}", + headers: { + "content-type": "application/json", + }, + method: "POST", + }); + + if (!submitResp.ok) { + let error; + + try { + error = ((await submitResp.json()) as { error: string }).error; + } catch { + error = "Unknown error"; + } + + toast({ + description: error, + isClosable: true, + status: "error", + title: "Oops", + }); + + return; + } + + toast({ + description: "User has been banned from appeals", + isClosable: true, + status: "success", + title: "Success", + }); + + props.onClose(); + } + + return ( + + + + New Appeal Ban + + + User ID + setUserID(e.target.value)} + placeholder="1234567890987654321" + /> + + + + + + + + ); +}