use fetchWrapper for getUserToValidate.js
This commit is contained in:
@@ -16,7 +16,8 @@ function PendingMembers() {
|
||||
useEffect(() => {
|
||||
const fetchPendingMembers = async () => {
|
||||
setLoading(true);
|
||||
const userIds = await getUserToValidate();
|
||||
const result = await getUserToValidate();
|
||||
const userIds = result.data
|
||||
if (userIds && userIds.length > 0) {
|
||||
const users = await Promise.all(userIds.map((id) => getUserById(id)));
|
||||
setPendingMembers(users.filter(Boolean));
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
import fetchWrapper from "../fetchWrapper.js";
|
||||
|
||||
export default async function getUserToValidate() {
|
||||
try {
|
||||
const res = await fetch(`${import.meta.env.VITE_API_URL}/api/users/invalid`, {
|
||||
method: 'GET',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`Erreur serveur : ${res.status}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
return data;
|
||||
} catch (err) {
|
||||
console.error('Erreur :', err);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return fetchWrapper("/api/users/invalid");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user