Maybe this time (yeah right lol)
This commit is contained in:
parent
e2cafd60b6
commit
77f5b2db26
@ -22,11 +22,10 @@ import {
|
||||
VStack,
|
||||
useToast,
|
||||
} from "@chakra-ui/react";
|
||||
import { type ReactElement, useState } from "react";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function (props: { isOpen: boolean; onClose: () => void }) {
|
||||
const actionMap: { [k: string]: number } = {};
|
||||
const [rows, setRows] = useState([] as ReactElement[]);
|
||||
const [users, setUsers] = useState([] as string[]);
|
||||
const toast = useToast();
|
||||
const fileTypes: { [k: string]: string } = {
|
||||
@ -48,35 +47,9 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
||||
|
||||
function addUser(user: string) {
|
||||
const newUsers = [...users];
|
||||
|
||||
newUsers.push(user);
|
||||
|
||||
const newRows = [...rows];
|
||||
newRows.push(
|
||||
<Tr key={user}>
|
||||
<Td>{user}</Td>
|
||||
<Td>
|
||||
<RadioGroup
|
||||
onChange={(val) =>
|
||||
Object.defineProperty(actionMap, user, {
|
||||
value: parseInt(val),
|
||||
})
|
||||
}
|
||||
>
|
||||
<VStack>
|
||||
<Radio value="0">Do Nothing</Radio>
|
||||
<Radio value="1">Hide from Leaderboards</Radio>
|
||||
<Radio value="2">Ban</Radio>
|
||||
</VStack>
|
||||
</RadioGroup>
|
||||
</Td>
|
||||
<Td>
|
||||
<Link onClick={() => removeUser(user)}>Remove</Link>
|
||||
</Td>
|
||||
</Tr>,
|
||||
);
|
||||
|
||||
setUsers(newUsers);
|
||||
setRows(newRows);
|
||||
}
|
||||
|
||||
function removeUser(user: string) {
|
||||
@ -85,12 +58,8 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
||||
|
||||
if (userIdx === -1) return;
|
||||
|
||||
const newRows = [...rows];
|
||||
|
||||
newUsers.splice(userIdx, 1);
|
||||
newRows.splice(userIdx, 1);
|
||||
setUsers(newUsers);
|
||||
setRows(newRows);
|
||||
|
||||
delete actionMap[user];
|
||||
}
|
||||
@ -99,7 +68,7 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
||||
(document.getElementById("username") as HTMLInputElement).value = "";
|
||||
(document.getElementById("evidence") as HTMLInputElement).value = "";
|
||||
|
||||
setRows([]);
|
||||
setUsers([]);
|
||||
Object.keys(actionMap).forEach((k) => delete actionMap[k]);
|
||||
|
||||
props.onClose();
|
||||
@ -243,7 +212,31 @@ export default function (props: { isOpen: boolean; onClose: () => void }) {
|
||||
<Th>Remove</Th>
|
||||
</Tr>
|
||||
</Thead>
|
||||
<Tbody>{rows}</Tbody>
|
||||
<Tbody>
|
||||
{users.map((user) => (
|
||||
<Tr key={user}>
|
||||
<Td>{user}</Td>
|
||||
<Td>
|
||||
<RadioGroup
|
||||
onChange={(val) =>
|
||||
Object.defineProperty(actionMap, user, {
|
||||
value: parseInt(val),
|
||||
})
|
||||
}
|
||||
>
|
||||
<VStack>
|
||||
<Radio value="0">Do Nothing</Radio>
|
||||
<Radio value="1">Hide from Leaderboards</Radio>
|
||||
<Radio value="2">Ban</Radio>
|
||||
</VStack>
|
||||
</RadioGroup>
|
||||
</Td>
|
||||
<Td>
|
||||
<Link onClick={() => removeUser(user)}>Remove</Link>
|
||||
</Td>
|
||||
</Tr>
|
||||
))}
|
||||
</Tbody>
|
||||
</Table>
|
||||
</TableContainer>
|
||||
<br />
|
||||
|
Loading…
x
Reference in New Issue
Block a user