mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-03 16:51:26 +00:00
fix: Possibilité d'ajouter un 2ème guardian, même si son mail est
associé à un profil existant
This commit is contained in:
@ -5,10 +5,12 @@ import { useTranslations } from 'next-intl';
|
||||
import { Trash2, Plus, Users } from 'lucide-react';
|
||||
import SectionHeader from '@/components/SectionHeader';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
import logger from '@/utils/logger';
|
||||
|
||||
export default function ResponsableInputFields({
|
||||
guardians,
|
||||
setGuardians,
|
||||
profiles,
|
||||
errors,
|
||||
setIsPageValid,
|
||||
enable = true,
|
||||
@ -70,8 +72,17 @@ export default function ResponsableInputFields({
|
||||
|
||||
// Synchroniser profile_data.email et profile_data.username avec associated_profile_email
|
||||
if (field === 'associated_profile_email') {
|
||||
updatedGuardian.profile_role_data.profile_data.email = value;
|
||||
updatedGuardian.profile_role_data.profile_data.username = value;
|
||||
const existingProfile = profiles?.find(
|
||||
(profile) => profile.email === value
|
||||
);
|
||||
if (existingProfile) {
|
||||
updatedGuardian.profile_role_data.profile = existingProfile.id;
|
||||
delete updatedGuardian.profile_role_data.profile_data;
|
||||
} else {
|
||||
updatedGuardian.profile_role_data.profile_data.email = value;
|
||||
updatedGuardian.profile_role_data.profile_data.username = value;
|
||||
delete updatedGuardian.profile_role_data.profile;
|
||||
}
|
||||
}
|
||||
|
||||
return updatedGuardian;
|
||||
|
||||
Reference in New Issue
Block a user