From ce87d19b9c8d33af487b910b997f48001bf6bf9c Mon Sep 17 00:00:00 2001
From: "gpt-engineer-app[bot]"
<159125892+gpt-engineer-app[bot]@users.noreply.github.com>
Date: Thu, 26 Sep 2024 01:08:09 +0000
Subject: [PATCH] Update staff console features
Removed unnecessary elements and blocks. Enhanced the staff console with a white background and added functionalities to ban players, display current players (excluding bots), and show account names and passwords of signed-up users.
[skip gpt_engineer]
---
src/components/Sidebar.jsx | 8 +--
src/components/StaffConsole.jsx | 98 +++++++++++++++++++++++++++------
2 files changed, 81 insertions(+), 25 deletions(-)
diff --git a/src/components/Sidebar.jsx b/src/components/Sidebar.jsx
index 88ee5ff..838b4b2 100644
--- a/src/components/Sidebar.jsx
+++ b/src/components/Sidebar.jsx
@@ -1,6 +1,6 @@
import React from 'react';
import { Link } from 'react-router-dom';
-import { RocketIcon, BoxIcon, AnchorIcon, CastleIcon, CupSodaIcon, CircleDotIcon, HeadphonesIcon, MessageSquareIcon } from 'lucide-react';
+import { RocketIcon, BoxIcon, AnchorIcon, CastleIcon, CupSodaIcon, CircleDotIcon } from 'lucide-react';
import { isStaff } from './ProtectedRoute';
const Sidebar = () => {
@@ -25,12 +25,6 @@ const Sidebar = () => {
-
-
-
-
-
-
{isStaff() && (
Staff
diff --git a/src/components/StaffConsole.jsx b/src/components/StaffConsole.jsx
index 5445bfb..94b50fa 100644
--- a/src/components/StaffConsole.jsx
+++ b/src/components/StaffConsole.jsx
@@ -1,10 +1,21 @@
-import React, { useState } from 'react';
+import React, { useState, useEffect } from 'react';
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
const StaffConsole = () => {
const [username, setUsername] = useState('');
const [amount, setAmount] = useState('');
+ const [banUsername, setBanUsername] = useState('');
+ const [currentPlayers, setCurrentPlayers] = useState([]);
+ const [registeredUsers, setRegisteredUsers] = useState([]);
+
+ useEffect(() => {
+ // Fetch current players and registered users
+ const users = JSON.parse(localStorage.getItem('users')) || [];
+ setCurrentPlayers(users.filter(user => user.isOnline));
+ setRegisteredUsers(users);
+ }, []);
const handleUpdateBalance = () => {
const users = JSON.parse(localStorage.getItem('users')) || [];
@@ -18,26 +29,77 @@ const StaffConsole = () => {
alert(`Updated balance for ${username} to $${amount}`);
};
+ const handleBanPlayer = () => {
+ const users = JSON.parse(localStorage.getItem('users')) || [];
+ const updatedUsers = users.map(user => {
+ if (user.username === banUsername) {
+ user.isBanned = true;
+ }
+ return user;
+ });
+ localStorage.setItem('users', JSON.stringify(updatedUsers));
+ alert(`Banned player: ${banUsername}`);
+ setBanUsername('');
+ };
+
return (
-
+
);
};
-export default StaffConsole;
\ No newline at end of file
+export default StaffConsole;