diff --git a/src/App.tsx b/src/App.tsx
index 2906abf..10d25a1 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -63,6 +63,10 @@ export default function App(): React.ReactElement {
Users
+ |
+
+ Whitelists
+
diff --git a/src/components/homePage.tsx b/src/components/homePage.tsx
index dbaa58e..9cff8ae 100644
--- a/src/components/homePage.tsx
+++ b/src/components/homePage.tsx
@@ -39,6 +39,12 @@ export default function HomePage(): React.ReactElement {
>
Ticket Menu
+
+ Whitelist Menu
+
diff --git a/src/components/whitelistPanel.tsx b/src/components/whitelistPanel.tsx
new file mode 100644
index 0000000..3ad7133
--- /dev/null
+++ b/src/components/whitelistPanel.tsx
@@ -0,0 +1,125 @@
+import React, { useEffect, useState } from "react";
+import { callApi } from "../helpers/api";
+import { NameExpand } from "./nameExpand";
+import { LinkColor } from "./link";
+import { Dialog } from "./dialog";
+
+type WhitelistPlayer = {
+ id: number;
+ ckey: string;
+ whitelistStatus: string;
+};
+
+type Filter = {
+ [index: string]: boolean | undefined;
+};
+
+export const WhitelistMenu: React.FC = () => {
+ const [whitelistees, setWhitelistees] = useState<
+ WhitelistPlayer[] | undefined
+ >();
+
+ const [categories, setCategories] = useState([]);
+
+ const [viewFilters, setViewFilters] = useState(false);
+ const [filter, setFilter] = useState({});
+
+ useEffect(() => {
+ if (whitelistees) return;
+
+ callApi("/Whitelist").then((value) =>
+ value.json().then((json: WhitelistPlayer[]) => {
+ setWhitelistees(json);
+
+ json.forEach((whitelistee) => {
+ whitelistee.whitelistStatus.split("|").forEach((status) => {
+ setCategories((categories) =>
+ categories.includes(status) ? categories : [...categories, status]
+ );
+ });
+ });
+ })
+ );
+ }, [whitelistees]);
+
+ useEffect(() => {
+ const obj: Filter = {};
+ categories.forEach((category) => {
+ obj[category] = true;
+ });
+ setFilter(obj);
+ }, [categories]);
+
+ const clearFilters = () => {
+ const obj: Filter = {};
+ categories.forEach((category) => {
+ obj[category] = false;
+ });
+ setFilter(obj);
+ };
+
+ if (!whitelistees) {
+ return "Loading...";
+ }
+
+ const filteredWhitelistees = whitelistees.filter((whitelistee) => {
+ const whitelists = whitelistee.whitelistStatus.split("|");
+
+ let filtered = true;
+
+ whitelists.forEach((whitelist) => {
+ if (filter[whitelist] == true) {
+ filtered = false;
+ }
+ });
+
+ if (filtered) return false;
+
+ return true;
+ });
+
+ return (
+
+
+
setViewFilters(true)}>Set Filters
+ {viewFilters && (
+
+ )}
+
+
+ {filteredWhitelistees.map((whitelistee) => (
+
+
+ {whitelistee.whitelistStatus.split("|").join(" ")}
+
+ ))}
+
+
+ );
+};
diff --git a/src/main.tsx b/src/main.tsx
index be92d31..181a9a2 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -7,6 +7,7 @@ import { Stickybans } from "./components/stickybans";
import { Tickets } from "./components/tickets";
import HomePage from "./components/homePage";
import { createHashRouter, RouterProvider } from "react-router-dom";
+import { WhitelistMenu } from "./components/whitelistPanel";
const router = createHashRouter([
{
@@ -38,6 +39,10 @@ const router = createHashRouter([
return params.ckey || "";
},
},
+ {
+ path: "/whitelists",
+ element: ,
+ },
],
},
]);