diff --git a/web/src/pages/ServerDashboard.tsx b/web/src/pages/ServerDashboard.tsx index ad61899..a74cd54 100644 --- a/web/src/pages/ServerDashboard.tsx +++ b/web/src/pages/ServerDashboard.tsx @@ -3,23 +3,38 @@ import axios from 'axios'; import { FunctionComponent, useCallback, useEffect, useState } from "react"; import { Button } from '@revoltchat/ui/lib/components/atoms/inputs/Button'; import { InputBox } from '@revoltchat/ui/lib/components/atoms/inputs/InputBox'; +import { Checkbox } from '@revoltchat/ui/lib/components/atoms/inputs/Checkbox'; import { H1 } from '@revoltchat/ui/lib/components/atoms/heading/H1'; +import { H3 } from '@revoltchat/ui/lib/components/atoms/heading/H3'; import { H4 } from '@revoltchat/ui/lib/components/atoms/heading/H4'; import { API_URL } from "../App"; import { getAuthHeaders } from "../utils"; import { useParams } from "react-router-dom"; -type Server = { id: string, perms: 0|1|2, name: string, iconURL?: string, bannerURL?: string } +type Server = { id?: string, perms?: 0|1|2, name?: string, description?: string, iconURL?: string, bannerURL?: string, serverConfig?: any } const ServerDashboard: FunctionComponent = () => { - const [serverInfo, setServerInfo] = useState({} as any); + const [serverInfo, setServerInfo] = useState({} as Server); const [status, setStatus] = useState(''); + + const [prefix, setPrefix] = useState('' as string|undefined); + const [prefixAllowSpace, setPrefixAllowSpace] = useState(false); + const { serverid } = useParams(); + const saveConfig = useCallback(async () => { + alert('server config saved (not really)'); + }, [ prefix, prefixAllowSpace ]); + const loadInfo = useCallback(async () => { try { const res = await axios.get(`${API_URL}/dash/server/${serverid}`, { headers: await getAuthHeaders() }); - setServerInfo(res.data.server); + console.log(res.data); + const server: Server = res.data.server; + setServerInfo(server); + + setPrefix(server.serverConfig?.prefix || undefined); + setPrefixAllowSpace(!!server.serverConfig?.spaceAfterPrefix); } catch(e: any) { console.error(e); setStatus(`${e?.message ?? e}`); @@ -33,7 +48,32 @@ const ServerDashboard: FunctionComponent = () => {

{serverInfo?.name ?? 'Loading...'}

{status.length ? {status} :
} );