mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
fix: Suppression d'un profil uniquement s'il ne contient aucun guardian
rattaché à un élève qui n'en a pas d'autre
This commit is contained in:
@ -885,20 +885,9 @@ export default function Page({ params: { locale } }) {
|
||||
{
|
||||
name: t('mainContactMail'),
|
||||
transform: (row) =>
|
||||
row.student.guardians && row.student.guardians.length > 0 ? (
|
||||
row.student.guardians && row.student.guardians.length > 0 && (
|
||||
row.student.guardians[0].associated_profile_email
|
||||
) : (
|
||||
<div className="flex justify-center h-full">
|
||||
<button
|
||||
className="flex items-center gap-2 text-blue-600 font-semibold hover:text-blue-800 transition duration-200 underline decoration-blue-600 hover:decoration-blue-800"
|
||||
onClick={() => handleOpenAddGuardian(row.student)}
|
||||
>
|
||||
<span className="px-3 py-1 bg-blue-100 rounded-full hover:bg-blue-200 transition duration-200">
|
||||
Ajouter un responsable
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
)
|
||||
},
|
||||
{
|
||||
name: t('phone'),
|
||||
|
||||
@ -92,15 +92,29 @@ export const updateProfileRoles = (id, data, csrfToken) => {
|
||||
return fetch(request).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const deleteProfileRoles = (id, csrfToken) => {
|
||||
const request = new Request(`${BE_AUTH_PROFILES_ROLES_URL}/${id}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
return fetch(request).then(requestResponseHandler);
|
||||
export const deleteProfileRoles = async (id, csrfToken) => {
|
||||
const response = await fetch(
|
||||
`${BE_AUTH_PROFILES_ROLES_URL}/${id}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
// Extraire le message d'erreur du backend
|
||||
const errorData = await response.json();
|
||||
const errorMessage =
|
||||
errorData?.error || 'Une erreur est survenue lors de la suppression du profil.';
|
||||
|
||||
// Jeter une erreur avec le message spécifique
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const fetchProfiles = () => {
|
||||
|
||||
Reference in New Issue
Block a user