From b220792b402cd7a03340c883e8c5fe342dedbd32 Mon Sep 17 00:00:00 2001 From: Reditus <33814724+ReditusDraco@users.noreply.github.com> Date: Sat, 23 May 2026 07:33:48 +0100 Subject: [PATCH] feat: add missing frontend routes and components - Add PlayerDetail route and all new page routes to App.tsx - Add Vehicles, Buildings, Map, Accounts, Files, Director, Settings to NavBar - Include Accounts page component - Include Director page component --- frontend/src/App.tsx | 16 +++ frontend/src/components/accounts/Accounts.tsx | 62 ++++++++ frontend/src/components/director/Director.tsx | 135 ++++++++++++++++++ frontend/src/components/layout/NavBar.tsx | 13 +- 4 files changed, 223 insertions(+), 3 deletions(-) create mode 100644 frontend/src/components/accounts/Accounts.tsx create mode 100644 frontend/src/components/director/Director.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d47d440..8aa6e13 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -4,11 +4,19 @@ import { useRealtime } from './hooks/useRealtime' import AppShell from './components/layout/AppShell' import Overview from './components/overview/Overview' import PlayerExplorer from './components/players/PlayerExplorer' +import PlayerDetail from './components/players/PlayerDetail' import GuildManager from './components/guilds/GuildManager' +import Vehicles from './components/vehicles/Vehicles' +import Buildings from './components/buildings/Buildings' +import MapViewer from './components/map/MapViewer' +import Accounts from './components/accounts/Accounts' import ServerControl from './components/server/ServerControl' import AdminTools from './components/admin/AdminTools' import ChatMonitor from './components/chat/ChatMonitor' import Terminal from './components/shell/Terminal' +import FileBrowser from './components/files/FileBrowser' +import Director from './components/director/Director' +import Settings from './components/settings/Settings' function RealtimeInit() { useRealtime() @@ -24,11 +32,19 @@ function App() { } /> } /> + } /> } /> + } /> + } /> + } /> + } /> } /> } /> } /> } /> + } /> + } /> + } /> diff --git a/frontend/src/components/accounts/Accounts.tsx b/frontend/src/components/accounts/Accounts.tsx new file mode 100644 index 0000000..04f993d --- /dev/null +++ b/frontend/src/components/accounts/Accounts.tsx @@ -0,0 +1,62 @@ +import { useState } from 'react' +import useSWR from 'swr' +import client from '../../api/client' +import { useApp } from '../../stores/AppContext' +import DataTable from '../common/DataTable' + +const fetcher = (url: string) => client.get(url).then((r) => r.data) + +interface Account { + id: number + email: string + funcom_id: string + character_count: number + is_demo: boolean + is_cheater: boolean + last_login: string +} + +export default function Accounts() { + const [search, setSearch] = useState('') + const { dispatch } = useApp() + + const { data: accountsData, isLoading } = useSWR( + search.length >= 2 ? `/accounts?q=${encodeURIComponent(search)}&limit=50` : '/accounts?limit=100', + fetcher, + { refreshInterval: 30000 } + ) + + const accountList: Account[] = accountsData?.success ? accountsData.data : [] + + return ( +
+

Accounts

+ +
+
+ setSearch(e.target.value)} + placeholder="Search accounts..." + className="w-full bg-card-bg border border-border rounded-lg px-4 py-2.5 pl-10 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-primary focus:ring-1 focus:ring-primary" + /> + + + +
+
+ + +
+ ) +} diff --git a/frontend/src/components/director/Director.tsx b/frontend/src/components/director/Director.tsx new file mode 100644 index 0000000..fa7b7ef --- /dev/null +++ b/frontend/src/components/director/Director.tsx @@ -0,0 +1,135 @@ +import { useState } from 'react' +import useSWR from 'swr' +import client from '../../api/client' +import { useApp } from '../../stores/AppContext' + +const fetcher = (url: string) => client.get(url).then((r) => r.data) + +export default function Director() { + const [tab, setTab] = useState<'battlegroup' | 'config' | 'transfer' | 'fls'>('battlegroup') + const { dispatch } = useApp() + + const { data: bgData } = useSWR('/director/battlegroup', fetcher, { refreshInterval: 15000 }) + + const handlePost = async (endpoint: string, payload: any) => { + try { + const res = await client.post(endpoint, payload) + if (res.data.success) { + dispatch({ type: 'ADD_TOAST', payload: { message: 'Success', type: 'success' } }) + } else { + dispatch({ type: 'ADD_TOAST', payload: { message: res.data.error || 'Failed', type: 'error' } }) + } + } catch (e: any) { + dispatch({ type: 'ADD_TOAST', payload: { message: e.response?.data?.error || 'Failed', type: 'error' } }) + } + } + + return ( +
+

Director Control

+ +
+ {([ + { key: 'battlegroup', label: 'Battlegroup' }, + { key: 'config', label: 'Config' }, + { key: 'transfer', label: 'Transfer' }, + { key: 'fls', label: 'FLS' }, + ] as const).map((t) => ( + + ))} +
+ + {tab === 'battlegroup' && ( +
+

Battlegroup State

+ {bgData?.success ? ( +
+              {JSON.stringify(bgData.data, null, 2)}
+            
+ ) : ( +
Loading battlegroup data...
+ )} +
+ )} + + {tab === 'config' && ( +
+

Update Config

+
+ + +
+
+ +