import axios from 'axios'; import { useNavigate } from 'react-router-dom'; import { FunctionComponent, useCallback, useEffect, useState } from "react"; import { Button } from '@revoltchat/ui/lib/components/atoms/inputs/Button'; import { H1 } from '@revoltchat/ui/lib/components/atoms/heading/H1'; import { H2 } from '@revoltchat/ui/lib/components/atoms/heading/H2'; import { API_URL } from "../App"; import { getAuthHeaders } from "../utils"; type Server = { id: string, perms: 0|1|2, name: string, iconURL?: string, bannerURL?: string } function permissionName(p: number) { switch(p) { case 0: return 'User'; case 1: return 'Moderator'; case 2: return 'Manager'; default: return 'Unknown'; } } const Dashboard: FunctionComponent = () => { const [loading, setLoading] = useState(true); const [servers, setServers] = useState([] as Server[]); const navigate = useNavigate(); const loadServers = useCallback(async () => { try { const res = await axios.get(API_URL + '/dash/servers', { headers: await getAuthHeaders() }); setServers(res.data.servers); setLoading(false); } catch(e) { console.error(e); } }, []); useEffect(() => { loadServers() }, []); return (

dashbord


{ servers.map(server =>

{server.name} ({permissionName(server.perms)})

{server.id}
) }
); } export default Dashboard;