Add distant links
This commit is contained in:
@@ -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} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user