feat: Ajout de la fratrie / Gestion des index de fratrie / Gestion des

required
This commit is contained in:
N3WT DE COMPET
2025-05-03 14:45:10 +02:00
parent 9374b001c9
commit 2ab1684791
9 changed files with 141 additions and 106 deletions

View File

@ -33,6 +33,7 @@ export default function ResponsableInputFields({
};
const getLocalError = (index, field) => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (
// Student Form
(field === 'last_name' &&
@ -43,7 +44,8 @@ export default function ResponsableInputFields({
guardians[index].first_name.trim() === '')) ||
(field === 'associated_profile_email' &&
(!guardians[index].associated_profile_email ||
guardians[index].associated_profile_email.trim() === '')) ||
guardians[index].associated_profile_email.trim() === '' ||
!emailRegex.test(guardians[index].associated_profile_email))) ||
(field === 'birth_date' &&
(!guardians[index].birth_date ||
guardians[index].birth_date.trim() === '')) ||
@ -138,10 +140,8 @@ export default function ResponsableInputFields({
onChange={(event) => {
onGuardiansChange(item.id, 'last_name', event.target.value);
}}
errorMsg={
getError(index, 'last_name') ||
getLocalError(index, 'last_name')
}
errorMsg={getError('last_name')}
errorLocalMsg={getLocalError(index, 'last_name')}
required
/>
<InputText
@ -152,10 +152,8 @@ export default function ResponsableInputFields({
onChange={(event) => {
onGuardiansChange(item.id, 'first_name', event.target.value);
}}
errorMsg={
getError(index, 'first_name') ||
getLocalError(index, 'first_name')
}
errorMsg={getError('first_name')}
errorLocalMsg={getLocalError(index, 'first_name')}
required
/>
</div>
@ -173,11 +171,9 @@ export default function ResponsableInputFields({
event.target.value
);
}}
errorMsg={getError('associated_profile_email')}
errorLocalMsg={getLocalError(index, 'associated_profile_email')}
required
errorMsg={
getError(index, 'associated_profile_email') ||
getLocalError(index, 'associated_profile_email')
}
/>
<InputPhone
name="telephoneResponsable"
@ -186,8 +182,9 @@ export default function ResponsableInputFields({
onChange={(event) => {
onGuardiansChange(item.id, 'phone', event.target.value);
}}
errorMsg={getError('phone')}
errorLocalMsg={getLocalError(index, 'phone')}
required
errorMsg={getError(index, 'phone')}
/>
</div>
@ -200,11 +197,9 @@ export default function ResponsableInputFields({
onChange={(event) => {
onGuardiansChange(item.id, 'birth_date', event.target.value);
}}
errorMsg={getError('birth_date')}
errorLocalMsg={getLocalError(index, 'birth_date')}
required
errorMsg={
getError(index, 'birth_date') ||
getLocalError(index, 'birth_date')
}
/>
<InputText
name="professionResponsable"
@ -214,11 +209,9 @@ export default function ResponsableInputFields({
onChange={(event) => {
onGuardiansChange(item.id, 'profession', event.target.value);
}}
errorMsg={getError('profession')}
errorLocalMsg={getLocalError(index, 'profession')}
required
errorMsg={
getError(index, 'profession') ||
getLocalError(index, 'profession')
}
/>
</div>
@ -231,10 +224,9 @@ export default function ResponsableInputFields({
onChange={(event) => {
onGuardiansChange(item.id, 'address', event.target.value);
}}
errorMsg={getError('address')}
errorLocalMsg={getLocalError(index, 'address')}
required
errorMsg={
getError(index, 'address') || getLocalError(index, 'address')
}
/>
</div>
</div>