From 6503af20f3ffe0bf44dc3afa87cff44cda7d3508 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:43 -0400 Subject: [PATCH] Add user table to game ban modal --- components/NewGameBan.tsx | 112 +++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/components/NewGameBan.tsx b/components/NewGameBan.tsx index 8ea12fc..8de4055 100644 --- a/components/NewGameBan.tsx +++ b/components/NewGameBan.tsx @@ -1,6 +1,8 @@ import { Button, + HStack, Input, + Link, Modal, ModalBody, ModalCloseButton, @@ -10,14 +12,72 @@ import { ModalOverlay, Radio, RadioGroup, + Table, + TableContainer, + Tbody, Text, + Td, + Th, + Thead, + Tr, + useToast, } from "@chakra-ui/react"; +import { useState } from "react"; export default function (props: { isOpen: boolean; onClose: () => void }) { + const actionMap: { [k: string]: number } = {}; + const [rows, setRows] = useState([] as JSX.Element[]); + + function addUser(user: string) { + const newRows = [...rows]; + newRows.push( + + {user} + + + Object.defineProperty(actionMap, user, { + value: parseInt(val), + }) + } + > + + Do Nothing + Hide from Leaderboards + Ban + + + + + removeUser(user)}>Remove + + + ); + } + + function removeUser(user: string) { + const newRows = [...rows]; + const el = newRows.find((el) => el.key === user); + + if (!el) return; + + const elIdx = newRows.indexOf(el); + + if (elIdx === -1) return; + + newRows.splice(elIdx, 1); + setRows(newRows); + + delete actionMap[user]; + } + function reset() { (document.getElementById("username") as HTMLInputElement).value = ""; (document.getElementById("evidence") as HTMLInputElement).value = ""; + setRows([]); + Object.keys(actionMap).forEach((k) => delete actionMap[k]); + props.onClose(); } @@ -29,9 +89,59 @@ export default function (props: { isOpen: boolean; onClose: () => void }) { Username(s) - + + +
+
+ + + + + + + + + + {rows} +
UsernamePunishmentRemove
+


+ Evidence +