diff --git a/Back-End/Subscriptions/models.py b/Back-End/Subscriptions/models.py
index 4b793b7..0f768f7 100644
--- a/Back-End/Subscriptions/models.py
+++ b/Back-End/Subscriptions/models.py
@@ -40,7 +40,6 @@ class Sibling(models.Model):
"""
Représente un frère ou une sœur d’un élève.
"""
- id = models.AutoField(primary_key=True)
last_name = models.CharField(max_length=200, default="")
first_name = models.CharField(max_length=200, default="")
birth_date = models.DateField(null=True, blank=True)
diff --git a/Back-End/Subscriptions/views/register_form_views.py b/Back-End/Subscriptions/views/register_form_views.py
index 3f3cad3..3a4c090 100644
--- a/Back-End/Subscriptions/views/register_form_views.py
+++ b/Back-End/Subscriptions/views/register_form_views.py
@@ -231,7 +231,6 @@ class RegisterFormWithIdView(APIView):
"""
studentForm_data = request.data.get('data', '{}')
- print(f'studentForm_data : {studentForm_data}')
try:
data = json.loads(studentForm_data)
except json.JSONDecodeError:
diff --git a/Front-End/src/components/InputText.js b/Front-End/src/components/InputText.js
index e2d6985..2ead301 100644
--- a/Front-End/src/components/InputText.js
+++ b/Front-End/src/components/InputText.js
@@ -5,6 +5,7 @@ export default function InputText({
value,
onChange,
errorMsg,
+ errorLocalMsg,
placeholder,
className,
required,
@@ -20,7 +21,11 @@ export default function InputText({
{required && *}
+ id && typeof id === 'string' && id.startsWith('temp-')
+ ? rest
+ : { id, ...rest }
+ ), // Supprimer les IDs temporaires
},
establishment: selectedEstablishmentId,
status: isSepaPayment ? 8 : 3,
@@ -398,6 +403,8 @@ export default function InscriptionFormShared({
formDataToSend.append('photo', formData.photo);
}
+ console.log('submit : ', jsonData);
+
// Appeler la fonction onSubmit avec les données FormData
onSubmit(formDataToSend);
};
diff --git a/Front-End/src/components/Inscription/PaymentMethodSelector.js b/Front-End/src/components/Inscription/PaymentMethodSelector.js
index 796465d..21f4daf 100644
--- a/Front-End/src/components/Inscription/PaymentMethodSelector.js
+++ b/Front-End/src/components/Inscription/PaymentMethodSelector.js
@@ -82,18 +82,18 @@ export default function PaymentMethodSelector({
label="Mode de Paiement"
placeHolder="Sélectionner un mode de paiement"
selected={formData.registration_payment}
- callback={(e) => onChange('registration_payment', e.target.value)}
+ callback={(e) =>
+ onChange('registration_payment', parseInt(e.target.value, 10))
+ }
choices={registrationPaymentModes.map((mode) => ({
value: mode.mode,
label:
paymentModesOptions.find((option) => option.id === mode.mode)
?.name || 'Mode inconnu',
}))}
+ errorMsg={getError('registration_payment')}
+ errorLocalMsg={getLocalError('registration_payment')}
required
- errorMsg={
- getError('registration_payment') ||
- getLocalError('registration_payment')
- }
/>
onChange('tuition_payment', e.target.value)}
+ callback={(e) =>
+ onChange('tuition_payment', parseInt(e.target.value, 10))
+ }
choices={tuitionPaymentModes.map((mode) => ({
value: mode.mode,
label:
paymentModesOptions.find((option) => option.id === mode.mode)
?.name || 'Mode inconnu',
}))}
+ errorMsg={getError('tuition_payment')}
+ errorLocalMsg={getLocalError('tuition_payment')}
required
- errorMsg={
- getError('tuition_payment') || getLocalError('tuition_payment')
- }
/>
onChange('tuition_payment_plan', e.target.value)}
+ handleChange={(e) => {
+ const value = parseInt(e.target.value, 10);
+ onChange('tuition_payment_plan', value); // Convertir la valeur en entier
+ }}
fieldName="tuition_payment_plan"
className="mt-4"
errorMsg={
diff --git a/Front-End/src/components/Inscription/ResponsableInputFields.js b/Front-End/src/components/Inscription/ResponsableInputFields.js
index e2397d4..231cce7 100644
--- a/Front-End/src/components/Inscription/ResponsableInputFields.js
+++ b/Front-End/src/components/Inscription/ResponsableInputFields.js
@@ -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
/>
{
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
/>
@@ -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')
- }
/>
{
onGuardiansChange(item.id, 'phone', event.target.value);
}}
+ errorMsg={getError('phone')}
+ errorLocalMsg={getLocalError(index, 'phone')}
required
- errorMsg={getError(index, 'phone')}
/>
@@ -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')
- }
/>
{
onGuardiansChange(item.id, 'profession', event.target.value);
}}
+ errorMsg={getError('profession')}
+ errorLocalMsg={getLocalError(index, 'profession')}
required
- errorMsg={
- getError(index, 'profession') ||
- getLocalError(index, 'profession')
- }
/>
@@ -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')
- }
/>
diff --git a/Front-End/src/components/Inscription/SiblingInputFields.js b/Front-End/src/components/Inscription/SiblingInputFields.js
index 0d9aff4..10cf0ba 100644
--- a/Front-End/src/components/Inscription/SiblingInputFields.js
+++ b/Front-End/src/components/Inscription/SiblingInputFields.js
@@ -2,6 +2,7 @@ import InputText from '@/components/InputText';
import React, { useEffect } from 'react';
import { Trash2, Plus, Users } from 'lucide-react';
import SectionHeader from '@/components/SectionHeader';
+import { v4 as uuidv4 } from 'uuid';
export default function SiblingInputFields({
siblings,
@@ -67,6 +68,7 @@ export default function SiblingInputFields({
setSiblings([
...siblings,
{
+ id: `temp-${uuidv4()}`,
last_name: '',
first_name: '',
birth_date: '',
@@ -105,10 +107,8 @@ export default function SiblingInputFields({
onChange={(event) => {
onSiblingsChange(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
/>
{
onSiblingsChange(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
/>
@@ -136,10 +134,8 @@ export default function SiblingInputFields({
onChange={(event) => {
onSiblingsChange(item.id, 'birth_date', event.target.value);
}}
- errorMsg={
- getError(index, 'birth_date') ||
- getLocalError(index, 'birth_date')
- }
+ errorMsg={getError('birth_date')}
+ errorLocalMsg={getLocalError(index, 'birth_date')}
required
/>
diff --git a/Front-End/src/components/Inscription/StudentInfoForm.js b/Front-End/src/components/Inscription/StudentInfoForm.js
index 459ee5b..46d7672 100644
--- a/Front-End/src/components/Inscription/StudentInfoForm.js
+++ b/Front-End/src/components/Inscription/StudentInfoForm.js
@@ -21,6 +21,11 @@ const levels = [
{ value: '9', label: 'CM2' },
];
+const genders = [
+ { value: '1', label: 'Garçon' },
+ { value: '2', label: 'Fille' },
+];
+
export default function StudentInfoForm({
studentId,
formData,
@@ -46,6 +51,7 @@ export default function StudentInfoForm({
photo: photoPath,
last_name: data?.student?.last_name || '',
first_name: data?.student?.first_name || '',
+ gender: data?.student?.gender || '',
address: data?.student?.address || '',
birth_date: data?.student?.birth_date || '',
birth_place: data?.student?.birth_place || '',
@@ -109,6 +115,8 @@ export default function StudentInfoForm({
(!formData.last_name || formData.last_name.trim() === '')) ||
(field === 'first_name' &&
(!formData.first_name || formData.first_name.trim() === '')) ||
+ (field === 'gender' &&
+ (!formData.gender || String(formData.gender).trim() === '')) ||
(field === 'nationality' &&
(!formData.nationality || formData.nationality.trim() === '')) ||
(field === 'birth_date' &&
@@ -124,8 +132,7 @@ export default function StudentInfoForm({
(!formData.attending_physician ||
formData.attending_physician.trim() === '')) ||
(field === 'level' &&
- (!formData.level || String(formData.level).trim() === '')) ||
- (field === 'photo' && !formData.photo)
+ (!formData.level || String(formData.level).trim() === ''))
) {
return 'Champs requis';
}
@@ -156,37 +163,44 @@ export default function StudentInfoForm({
return (
<>
-
+
-
+
onChange('last_name', e.target.value)}
required
- errorMsg={getError('last_name') || getLocalError('last_name')}
+ errorMsg={getError('last_name')}
+ errorLocalMsg={getLocalError('last_name')}
/>
onChange('first_name', e.target.value)}
- errorMsg={getError('first_name') || getLocalError('first_name')}
+ errorMsg={getError('first_name')}
+ errorLocalMsg={getLocalError('first_name')}
required
/>
- onChange('gender', e.target.value)}
+ choices={genders}
required
- onChange={(e) => onChange('nationality', e.target.value)}
- errorMsg={getError('nationality') || getLocalError('nationality')}
+ errorMsg={getError('gender')}
+ errorLocalMsg={getLocalError('gender')}
/>
+
+
onChange('birth_date', e.target.value)}
required
- errorMsg={getError('birth_date') || getLocalError('birth_date')}
+ errorMsg={getError('birth_date')}
+ errorLocalMsg={getLocalError('birth_date')}
/>
onChange('birth_place', e.target.value)}
required
- errorMsg={getError('birth_place') || getLocalError('birth_place')}
+ errorMsg={getError('birth_place')}
+ errorLocalMsg={getLocalError('birth_place')}
/>
onChange('birth_postal_code', e.target.value)}
required
- errorMsg={
- getError('birth_postal_code') ||
- getLocalError('birth_postal_code')
- }
+ errorMsg={getError('birth_postal_code')}
+ errorLocalMsg={getLocalError('birth_postal_code')}
/>
-
- onChange('address', e.target.value)}
- required
- errorMsg={getError('address') || getLocalError('address')}
- />
-
+
+
+ onChange('nationality', e.target.value)}
+ errorMsg={getError('nationality')}
+ errorLocalMsg={getLocalError('nationality')}
+ />
+ onChange('address', e.target.value)}
+ required
+ errorMsg={getError('address')}
+ errorLocalMsg={getLocalError('address')}
+ />
+
+
onChange('attending_physician', e.target.value)}
required
- errorMsg={
- getError('attending_physician') ||
- getLocalError('attending_physician')
- }
+ errorMsg={getError('attending_physician')}
+ errorLocalMsg={getLocalError('attending_physician')}
/>
onChange('level', e.target.value)}
choices={levels}
required
- errorMsg={getError('level') || getLocalError('level')}
+ errorMsg={getError('level')}
+ errorLocalMsg={getLocalError('level')}
+ />
+
+
+ handlePhotoUpload(file)}
+ existingFile={formData.photo}
+ errorMsg={getError('photo')}
/>
-
-
- {/* Section pour l'upload des fichiers */}
-
-
- handlePhotoUpload(file)}
- existingFile={formData.photo}
- required
- errorMsg={getError('photo') || getLocalError('photo')}
- />
>
);
diff --git a/Front-End/src/components/SelectChoice.js b/Front-End/src/components/SelectChoice.js
index 6da947e..d35c25e 100644
--- a/Front-End/src/components/SelectChoice.js
+++ b/Front-End/src/components/SelectChoice.js
@@ -8,9 +8,11 @@ export default function SelectChoice({
callback,
selected,
errorMsg,
+ errorLocalMsg,
IconItem,
disabled = false,
}) {
+ const isPlaceholderSelected = selected === ''; // Vérifie si le placeholder est sélectionné
return (
<>
@@ -22,7 +24,11 @@ export default function SelectChoice({
{required &&
*}
{IconItem && (
@@ -30,7 +36,9 @@ export default function SelectChoice({
)}