import { WithLabeledEntities } from "@/interfaces/entity"; import { Type, User } from "@/interfaces/user"; import axios from "axios"; import { useEffect, useState } from "react"; export default function useEntitiesUsers(type?: Type) { const [users, setUsers] = useState[]>([]); const [isLoading, setIsLoading] = useState(false); const [isError, setIsError] = useState(false); const getData = () => { setIsLoading(true); axios .get[]>( `/api/entities/users${type ? "?type=" + type : ""}` ) .then((response) => setUsers(response.data)) .finally(() => setIsLoading(false)); }; useEffect(getData, [type]); return { users, isLoading, isError, reload: getData }; }