Implemented a simple page to view the currently registered users
This commit is contained in:
19
src/hooks/useUsers.tsx
Normal file
19
src/hooks/useUsers.tsx
Normal 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};
|
||||
}
|
||||
Reference in New Issue
Block a user