import { Box, Button, Card, CardBody, CardFooter, CardHeader, Heading, HStack, Radio, RadioGroup, Spacer, Stack, Text, useToast, VStack, } from "@chakra-ui/react"; import { useState } from "react"; export default function (props: ReportCardProps & { port?: MessagePort }) { const [attachmentIdx, setAttachmentIdx] = useState(0); const [loading, setLoading] = useState(false); const toast = useToast(); const targetMap: { [k: number]: string } = {}; const actionMap: { [k: number]: number } = {}; for (let i = 0; i < props.target_ids.length; i++) targetMap[props.target_ids[i]] = props.target_usernames[i]; async function submitActions() { setLoading(true); const submitReq = await fetch(`/api/reports/${props.id}/action`, { body: JSON.stringify(actionMap), headers: { "content-type": "application/json", }, method: "POST", }); if (!submitReq.ok) { setLoading(false); toast({ description: ((await submitReq.json()) as { error: string }).error, status: "error", title: "S̸̯̜̈́o̴̳̅̾̏̽m̴͔͕̈́̋ē̴̙͓̯̍̃ț̸͖̘̀h̶̛̳̝̐i̵̋͘͜ņ̷̙̤͌g̴̭̻̓̈́ ̴̘͍̦̪̆w̸̡̏̑̊é̸̠̖̹̂͜n̴̖̳̤̕t̴͚̊̊̕ ̸̛͙̺̬̎́w̴͈͑̋͊r̷̢̛o̵̱̩̍͋ͅṇ̸̝̰̮́g̵̡̢̦͕͂", }); return; } toast({ description: "Actions were successfully applied", status: "success", title: "Success", }); setLoading(false); props.port?.postMessage(`report_${props.id}`); } return ( Report for {props.target_usernames.toString()} ID(s): {props.target_ids.toString()}

{props.description}
{(function () { const radioGroups = []; for (let i = 0; i < props.target_ids.length; i++) { radioGroups.push( { actionMap[props.target_ids[i]] = parseInt(val); }} > {props.target_usernames[i]} Ignore Hide from Leaderboards Ban , ); } return radioGroups; })()}
); }