récupération modifs dev sur new branch

This commit is contained in:
p2405951
2026-01-06 09:32:20 +01:00
parent cab258ff51
commit a90d52b44b
5 changed files with 107 additions and 21 deletions
+22
View File
@@ -0,0 +1,22 @@
export default async function deleteUser(userId) {
try {
const res = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/${userId}`, {
method: 'DELETE',
credentials: 'include',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
});
if (!res.ok) {
throw new Error(`Erreur serveur : ${res.status}`);
}
const data = await res.json();
return data;
} catch (err) {
console.error('Erreur lors de la suppression :', err);
return null;
}
}
+21
View File
@@ -0,0 +1,21 @@
export default async function getUserToValidate() {
try {
const res = await fetch(`http://${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;
}
}
+22
View File
@@ -0,0 +1,22 @@
export default async function validateUser(userId) {
try {
const res = await fetch(`http://${import.meta.env.VITE_API_URL}/api/users/${userId}/validate`, {
method: 'POST',
credentials: 'include',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
});
if (!res.ok) {
throw new Error(`Erreur serveur : ${res.status}`);
}
const data = await res.json();
return data;
} catch (err) {
console.error('Erreur lors de la validation :', err);
return null;
}
}