diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/pages/Dashboard.tsx index ce5c9e0..cb9b023 100644 --- a/frontend/src/pages/Dashboard.tsx +++ b/frontend/src/pages/Dashboard.tsx @@ -1,3 +1,78 @@ +import { useEffect, useState } from "react"; +import api from "../Api"; +import { Layout } from "../components/Layout"; +import type { Server } from "../types/Server"; + export const Dashboard = () => { - return
Dashboard Page
; -}; \ No newline at end of file + const [servers, setServers] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + const fetchServers = async () => { + try { + const { data } = await api.get("/api/servers"); + setServers(data); + } catch (err: any) { + const message = err?.response?.data?.message || "Falha ao carregar servidores."; + setError(message); + } finally { + setLoading(false); + } + }; + + fetchServers(); + }, []); + + return ( + +
+

Servidores

+ +
+ {loading &&
Carregando servidores...
} + {error &&
{error}
} + {!loading && !error && servers.length === 0 && ( +
Nenhum servidor encontrado.
+ )} + {!loading && !error && servers.length > 0 && ( +
+ + + + + + + + + + + + + + {servers.map((server) => ( + + + + + + + + + + ))} + +
NomeIPPortaUsuárioTipoAplicaçãoBanco
{server.name}{server.ip}{server.port}{server.user}{server.type.toLowerCase()}{server.application.toLowerCase()}{server.dbType.toLowerCase()}
+
+ )} +
+
+
+ ); +}; + +const Styles = { + card: "bg-card border border-cardBorder shadow-sm rounded-lg overflow-hidden", + tableHeadCell: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-text-secondary", + rowCell: "px-4 py-3 text-sm text-text", +};