import { Alert, AlertDescription, AlertIcon, AlertTitle, Box, Button, Container, Flex, Heading, Modal, ModalBody, ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalOverlay, Spacer, Text, Textarea, useDisclosure, useToast, } from "@chakra-ui/react"; import { useLoaderData } from "@remix-run/react"; import { useState } from "react"; import Success from "../../components/Success.js"; export async function loader({ context }: { context: RequestContext }) { if (!context.data.current_user) throw new Response(null, { status: 401, }); const { current_user: currentUser } = context.data; const dataKV = context.env.DATA; const disabled = await dataKV.get("appeal_disabled"); return { can_appeal: !Boolean(disabled) && !Boolean(await dataKV.get(`blockedappeal_${currentUser.id}`)) && !Boolean( ( await dataKV.list({ prefix: `appeal_${currentUser.id}`, }) ).keys.length, ), can_toggle: currentUser.permissions & (1 << 0) || currentUser.permissions & (1 << 11), disabled: Boolean(disabled), }; } export function meta() { return [ { title: "Appeals - Car Crushers", }, ]; } export default function () { const pageProps = useLoaderData(); const { isOpen, onClose, onOpen } = useDisclosure(); const [showSuccess, setShowSuccess] = useState(false); const toast = useToast(); async function submit() { const learned = (document.getElementById("learned") as HTMLInputElement) .value; const whyBanned = (document.getElementById("whyBanned") as HTMLInputElement) .value; const whyUnban = (document.getElementById("whyUnban") as HTMLInputElement) .value; const submitReq = await fetch("/api/appeals/submit", { body: JSON.stringify({ learned, whyBanned, whyUnban, }), headers: { "content-type": "application/json", }, method: "POST", }).catch(() => {}); if (!submitReq) return toast({ description: "Please check your internet and try again", duration: 10000, isClosable: true, status: "error", title: "Request Failed", }); if (!submitReq.ok) return toast({ description: ((await submitReq.json()) as { error: string }).error, duration: 10000, isClosable: true, status: "error", title: "Error", }); setShowSuccess(true); } async function toggle(active: boolean) { const toggleReq = await fetch("/api/appeals/toggle", { body: JSON.stringify({ active }), headers: { "content-type": "application/json", }, method: "POST", }); if (!toggleReq.ok) return toast({ description: ((await toggleReq.json()) as { error: string }).error, duration: 10000, isClosable: true, status: "error", title: "Error", }); toast({ description: `The appeals form is now ${active ? "opened" : "closed"}.`, isClosable: true, status: "success", title: `Appeals ${active ? "enabled" : "disabled"}`, }); onClose(); await new Promise((p) => setTimeout(p, 5000)); } return showSuccess ? ( ) : ( Appeals Closed We are currently not accepting appeals.
Toggle appeals? Are you sure you want to{" "} {pageProps.disabled ? "enable" : "disable"} appeals? Discord Appeals
This is for Discord bans only! See the support page if you were banned from the game.

Why were you banned?