Add distant links

This commit is contained in:
Romulus21
2025-12-26 15:53:19 +01:00
parent 9362dbe400
commit 4c6daa1c6c
5 changed files with 107 additions and 17 deletions

View File

@@ -3,7 +3,13 @@ import { LinkGroup } from "./App";
export const CastesLinks = () => {
const [loading, setLoading] = useState(true);
const links = [{ name: "GPAO", link: "http://gpao.lan" }];
const [error, setError] = useState("");
const [links, setLinks] = useState([]);
const castesLinks = [
{ name: "GPAO", link: "http://gpao.lan" },
{ name: "Penpot", link: "https://penpot.castes-industrie.fr" },
{ name: "Schema", link: "http://schemas.castes-industrie.fr/" },
];
useEffect(() => {
testConnection();
@@ -11,9 +17,30 @@ export const CastesLinks = () => {
const testConnection = async () => {
try {
const res = await fetch("http://gpao.lan");
const res = await fetch("http://gpao.lan", { method: "HEAD" });
console.log(res);
if (res.ok) {
setLinks(castesLinks);
}
console.log("link", res);
} catch (error) {}
} catch (error: Error | NetworkError | unknown) {
console.log(error);
setError(error.response?.data.message || error.message);
} finally {
setLoading(false);
}
};
return <LinkGroup title="Castes" links={links} />;
return loading ? (
<div>Chargement...</div>
) : (
<>
<div>Casty</div>
{error && (
<div className="text-white px-2 text-center py-1 mx-5 bg-red-500 rounded">
{error}
</div>
)}
<LinkGroup title="Castes" links={links} />
</>
);
};