= ({ link }) => {
>
{link.icon ? (
-

+
{link.name}
) : (
diff --git a/src/CastesLinks.tsx b/src/CastesLinks.tsx
index 2e1ca0e..0fea6fb 100644
--- a/src/CastesLinks.tsx
+++ b/src/CastesLinks.tsx
@@ -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 ;
+ return loading ? (
+ Chargement...
+ ) : (
+ <>
+ Casty
+ {error && (
+
+ {error}
+
+ )}
+
+ >
+ );
};
diff --git a/src/LocalLinks.tsx b/src/LocalLinks.tsx
new file mode 100644
index 0000000..7f5f42a
--- /dev/null
+++ b/src/LocalLinks.tsx
@@ -0,0 +1,41 @@
+import { useEffect, useState } from "react";
+import { LinkGroup } from "./App";
+
+export const LocalLinks = () => {
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(false);
+ const [links, setLinks] = useState([]);
+
+ useEffect(() => {
+ testConnection();
+ }, []);
+
+ const testConnection = async () => {
+ try {
+ const res = await fetch(
+ "http://192.168.3.42:3002/api/get_links2091652955602628755",
+ //"http://raspitipi.local:3002/api/get_links2091652955602628755",
+ );
+ const data = await res.json();
+ console.log(data, res);
+ setLinks(data);
+ console.log("link", res);
+ } catch (_: unknown) {
+ setError(true);
+ } finally {
+ setLoading(false);
+ }
+ };
+ return loading ? (
+ Chargement...
+ ) : (
+ <>
+
+ {error ? (
+
+ Liens non accessibles
+
+ ) : null}
+ >
+ );
+};