diff --git a/components/ReportCard.tsx b/components/ReportCard.tsx new file mode 100644 index 0000000..24714cc --- /dev/null +++ b/components/ReportCard.tsx @@ -0,0 +1,100 @@ +import { + Box, + Button, + Card, + CardBody, + CardFooter, + CardHeader, + Heading, + Radio, + RadioGroup, + Stack, + Text, +} from "@chakra-ui/react"; +import { useState } from "react"; + +export default function (props: { + attachment: string; + attachment_loading?: boolean; + reporter?: { [k: string]: any }; + target_ids: number[]; + target_usernames: string[]; +}) { + const targetMap: { [k: number]: string } = {}; + const [attachmentReady, setAttachmentReady] = useState( + !props.attachment_loading + ); + const actionMap: { [k: number]: number } = {}; + + for (let i = 0; i < props.target_ids.length; i++) + Object.defineProperty(targetMap, props.target_ids[i], { + value: props.target_usernames[i], + }); + + async function recheckAttachment() { + const attachmentCheck = await fetch(`/api/uploads/${props.attachment}`, { + method: "HEAD", + }); + + setAttachmentReady(attachmentCheck.ok); + } + + return ( + + + + Report for {props.target_usernames.toString()} + + ID(s): {props.target_ids.toString()} + + + {attachmentReady ? ( + Attachment processing... + ) : ( + + + {props.attachment_loading ? ( + + ) : ( + + {Object.entries(targetMap).map(([id, username]) => { + return ( + + Object.defineProperty(actionMap, parseInt(id), { + value: parseInt(val), + }) + } + > + + {username} + + Ignore + + + Hide from Leaderboards + + + Ban + + + + ); + })} + + + + + )} + + + ); +}