Fix types
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { LinkGroup } from "./App";
|
||||
import type { ApiError, LinkInterface } from "./types";
|
||||
|
||||
export const CastesLinks = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState("");
|
||||
const [links, setLinks] = useState([]);
|
||||
const [links, setLinks] = useState<LinkInterface[]>([]);
|
||||
const castesLinks = [
|
||||
{ name: "GPAO", link: "http://gpao.lan" },
|
||||
{ name: "Penpot", link: "https://penpot.castes-industrie.fr" },
|
||||
@@ -23,9 +24,13 @@ export const CastesLinks = () => {
|
||||
setLinks(castesLinks);
|
||||
}
|
||||
console.log("link", res);
|
||||
} catch (error: Error | NetworkError | unknown) {
|
||||
} catch (error: Error | ApiError | unknown) {
|
||||
console.log(error);
|
||||
setError(error.response?.data.message || error.message);
|
||||
if (error instanceof Error) {
|
||||
console.error(error.message);
|
||||
} else {
|
||||
setError((error as ApiError).error);
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user