Implemented a simple page to view the currently registered users

This commit is contained in:
Tiago Ribeiro
2023-04-14 12:34:56 +01:00
parent 399e222791
commit f88db929f4
16 changed files with 433 additions and 32 deletions

19
src/hooks/useUsers.tsx Normal file
View File

@@ -0,0 +1,19 @@
import {User} from "@/interfaces/user";
import axios from "axios";
import {useEffect, useState} from "react";
export default function useUsers() {
const [users, setUsers] = useState<User[]>([]);
const [isLoading, setIsLoading] = useState(false);
const [isError, setIsError] = useState(false);
useEffect(() => {
setIsLoading(true);
axios
.get<User[]>("/api/users/list")
.then((response) => setUsers(response.data))
.finally(() => setIsLoading(false));
}, []);
return {users, isLoading, isError};
}