mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
feat: Amélioration de la fiche élève pour y ajouter la fratrie et les
modalités de paimenet (problème affichage photo)
This commit is contained in:
@ -33,6 +33,15 @@ class Guardian(models.Model):
|
||||
profession = models.CharField(max_length=200, default="", blank=True)
|
||||
profile_role = models.OneToOneField(ProfileRole, on_delete=models.CASCADE, related_name='guardian_profile', blank=True)
|
||||
|
||||
@property
|
||||
def email(self):
|
||||
"""
|
||||
Retourne l'email du profil associé via le ProfileRole.
|
||||
"""
|
||||
if self.profile_role and self.profile_role.profile:
|
||||
return self.profile_role.profile.email
|
||||
return None
|
||||
|
||||
def __str__(self):
|
||||
return self.last_name + "_" + self.first_name
|
||||
|
||||
@ -144,6 +153,15 @@ class Student(models.Model):
|
||||
"""
|
||||
return self.siblings.count()
|
||||
|
||||
def get_photo_url(self):
|
||||
"""
|
||||
Retourne le chemin correct de la photo pour le template HTML.
|
||||
Si la photo n'existe pas, retourne le chemin de l'image par défaut.
|
||||
"""
|
||||
if self.photo and hasattr(self.photo, 'url'):
|
||||
# Retourne l'URL complète de la photo
|
||||
return self.photo.url
|
||||
|
||||
@property
|
||||
def age(self):
|
||||
if self.birth_date:
|
||||
|
||||
@ -1,230 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{{ pdf_title }}</title>
|
||||
<style>
|
||||
@page {
|
||||
size: A4;
|
||||
margin: 2cm;
|
||||
}
|
||||
body {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
font-size: 11pt;
|
||||
line-height: 1.3;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color:#333;
|
||||
}
|
||||
.container {
|
||||
width: 100%;
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 2px solid #333;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.title {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.section {
|
||||
margin-bottom: 15px; /* Réduit de 25px à 15px */
|
||||
padding: 10px; /* Réduit de 15px à 10px */
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 16pt;
|
||||
font-weight: bold;
|
||||
margin: 0 0 10px 0; /* Réduit de 15px à 10px */
|
||||
padding-bottom: 3px; /* Réduit de 5px à 3px */
|
||||
border-bottom: 1px solid #333;
|
||||
text-align: center;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
td {
|
||||
padding: 4px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.label-cell {
|
||||
font-weight: bold;
|
||||
width: 150px;
|
||||
}
|
||||
.value-cell {
|
||||
width: auto;
|
||||
}
|
||||
.half-row td {
|
||||
width: 50%;
|
||||
}
|
||||
.subsection-title {
|
||||
font-size: 12pt;
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px; /* Réduit de 10px à 5px */
|
||||
}
|
||||
.signature {
|
||||
margin-top: 30px;
|
||||
text-align: right;
|
||||
font-style: italic;
|
||||
}
|
||||
.signature-text {
|
||||
font-weight: bold;
|
||||
}
|
||||
.clearfix::after {
|
||||
content: "";
|
||||
clear: both;
|
||||
display: table;
|
||||
}
|
||||
p {
|
||||
margin: 0; /* Ajout de margin 0 pour les paragraphes */
|
||||
padding: 0; /* Ajout de padding 0 pour les paragraphes */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% load myTemplateTag %}
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div style="position: relative;">
|
||||
<h1 class="title">{{ pdf_title }}</h1>
|
||||
{% if student.photo %}
|
||||
<img
|
||||
src="{{ student.photo }}"
|
||||
alt="Photo de l'élève"
|
||||
style="
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
object-fit: cover;
|
||||
border: 2px solid #333;
|
||||
border-radius: 10px;
|
||||
"
|
||||
/>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">ÉLÈVE</h2>
|
||||
{% with level=student|getStudentLevel %}
|
||||
{% with gender=student|getStudentGender %}
|
||||
<table>
|
||||
<tr class="half-row">
|
||||
<td class="label-cell">NOM :</td>
|
||||
<td>{{ student.last_name }}</td>
|
||||
<td class="label-cell">PRÉNOM :</td>
|
||||
<td>{{ student.first_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">ADRESSE :</td>
|
||||
<td colspan="3">{{ student.address }}</td>
|
||||
</tr>
|
||||
<tr class="half-row">
|
||||
<td class="label-cell">GENRE :</td>
|
||||
<td>{{ gender }}</td>
|
||||
<td class="label-cell">NÉ(E) LE :</td>
|
||||
<td>{{ student.birth_date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">À :</td>
|
||||
<td colspan="3">{{ student.birth_place }} ({{ student.birth_postal_code }})</td>
|
||||
</tr>
|
||||
<tr class="half-row">
|
||||
<td class="label-cell">NATIONALITÉ :</td>
|
||||
<td>{{ student.nationality }}</td>
|
||||
<td class="label-cell">NIVEAU :</td>
|
||||
<td>{{ level }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">MÉDECIN TRAITANT :</td>
|
||||
<td colspan="3">{{ student.attending_physician }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
{% endwith %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">RESPONSABLES</h2>
|
||||
{% with guardians=student.getGuardians %}
|
||||
{% for guardian in guardians%}
|
||||
<div class="subsection">
|
||||
<h3 class="subsection-title">Responsable {{ forloop.counter }}</h3>
|
||||
<table>
|
||||
<tr class="half-row">
|
||||
<td class="label-cell">NOM :</td>
|
||||
<td>{{ guardian.last_name }}</td>
|
||||
<td class="label-cell">PRÉNOM :</td>
|
||||
<td>{{ guardian.first_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">ADRESSE :</td>
|
||||
<td colspan="3">{{ guardian.address }}</td>
|
||||
</tr>
|
||||
<tr class="half-row">
|
||||
<td class="label-cell">NÉ(E) LE :</td>
|
||||
<td>{{ guardian.birth_date }}</td>
|
||||
<td class="label-cell">EMAIL :</td>
|
||||
<td>{{ guardian.email }}</td>
|
||||
</tr>
|
||||
<tr class="half-row">
|
||||
<td class="label-cell">TÉLÉPHONE :</td>
|
||||
<td>{{ guardian.phone }}</td>
|
||||
<td class="label-cell">PROFESSION :</td>
|
||||
<td>{{ guardian.profession }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">FRATRIE</h2>
|
||||
{% with siblings=student.getGuardians %}
|
||||
{% for sibling in siblings%}
|
||||
<div class="subsection">
|
||||
<h3 class="subsection-title">Frère/Sœur {{ forloop.counter }}</h3>
|
||||
<table>
|
||||
<tr class="half-row">
|
||||
<td class="label-cell">NOM :</td>
|
||||
<td>{{ sibling.last_name }}</td>
|
||||
<td class="label-cell">PRÉNOM :</td>
|
||||
<td>{{ sibling.first_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">NÉ(E) LE :</td>
|
||||
<td colspan="3">{{ sibling.birth_date }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2 class="section-title">MODALITÉS DE PAIEMENT</h2>
|
||||
<h3 class="subsection-title">Frais d'inscription</h3>
|
||||
{% with registrationPayment=student|getRegistrationPaymentMethod %}
|
||||
<p>{{ registrationPayment }}</p>
|
||||
{% endwith %}
|
||||
<h3 class="subsection-title">Frais de scolarité</h3>
|
||||
{% with tuitionPayment=student|getTuitionPaymentMethod %}
|
||||
<p>{{ tuitionPayment }}</p>
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
<div class="signature">
|
||||
Fait le <span class="signature-text">{{ signatureDate }}</span> à <span class="signature-text">{{ signatureTime }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
233
Back-End/Subscriptions/templates/pdfs/fiche_eleve.html
Normal file
233
Back-End/Subscriptions/templates/pdfs/fiche_eleve.html
Normal file
@ -0,0 +1,233 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Fiche élève de {{ student.last_name }} {{ student.first_name }}</title>
|
||||
<style>
|
||||
@page {
|
||||
size: A4;
|
||||
margin: 2cm;
|
||||
}
|
||||
body {
|
||||
font-family: 'Arial', sans-serif;
|
||||
font-size: 12pt;
|
||||
line-height: 1.6;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #333;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
.container {
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 30px;
|
||||
border-bottom: 3px solid #4CAF50;
|
||||
padding-bottom: 15px;
|
||||
position: relative;
|
||||
}
|
||||
.title {
|
||||
font-size: 20pt;
|
||||
font-weight: bold;
|
||||
color: #4CAF50;
|
||||
margin: 0;
|
||||
}
|
||||
.photo {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
object-fit: cover;
|
||||
border: 2px solid #4CAF50;
|
||||
border-radius: 10px;
|
||||
}
|
||||
.section {
|
||||
margin-bottom: 20px;
|
||||
padding: 15px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
background-color: #fefefe;
|
||||
}
|
||||
.section-title {
|
||||
font-size: 18pt;
|
||||
font-weight: bold;
|
||||
color: #4CAF50;
|
||||
margin-bottom: 10px;
|
||||
text-align: left;
|
||||
border-bottom: 2px solid #4CAF50;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-top: 10px;
|
||||
}
|
||||
td {
|
||||
padding: 8px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.label-cell {
|
||||
font-weight: bold;
|
||||
color: #555;
|
||||
width: 35%;
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.value-cell {
|
||||
color: #333;
|
||||
width: 65%;
|
||||
text-align: left;
|
||||
}
|
||||
.phone {
|
||||
white-space: nowrap;
|
||||
}
|
||||
.signature {
|
||||
margin-top: 30px;
|
||||
text-align: right;
|
||||
font-style: italic;
|
||||
color: #555;
|
||||
}
|
||||
.signature-text {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
{% load myTemplateTag %}
|
||||
<div class="container">
|
||||
<!-- Header Section -->
|
||||
<div class="header">
|
||||
<h1 class="title">Fiche élève de {{ student.last_name }} {{ student.first_name }}</h1>
|
||||
{% if student.photo %}
|
||||
<img
|
||||
src="{{ student.get_photo_url }}"
|
||||
alt="Photo de l'élève"
|
||||
class="photo"
|
||||
/>
|
||||
{% else %}
|
||||
<img
|
||||
src="/static/img/default-photo.jpg"
|
||||
alt="Photo par défaut"
|
||||
class="photo"
|
||||
/>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Student Section -->
|
||||
<div class="section">
|
||||
<h2 class="section-title">ÉLÈVE</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label-cell">Nom :</td>
|
||||
<td class="value-cell">{{ student.last_name }}</td>
|
||||
<td class="label-cell">Prénom :</td>
|
||||
<td class="value-cell">{{ student.first_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">Adresse :</td>
|
||||
<td colspan="3" class="value-cell">{{ student.address }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">Genre :</td>
|
||||
<td class="value-cell">{{ student|getStudentGender }}</td>
|
||||
<td class="label-cell">Né(e) le :</td>
|
||||
<td class="value-cell">{{ student.birth_date }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">À :</td>
|
||||
<td colspan="3" class="value-cell">{{ student.birth_place }} ({{ student.birth_postal_code }})</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">Nationalité :</td>
|
||||
<td class="value-cell">{{ student.nationality }}</td>
|
||||
<td class="label-cell">Niveau :</td>
|
||||
<td class="value-cell">{{ student|getStudentLevel }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Guardians Section -->
|
||||
<div class="section">
|
||||
<h2 class="section-title">RESPONSABLES</h2>
|
||||
{% for guardian in student.getGuardians %}
|
||||
<div class="subsection">
|
||||
<h3 class="subsection-title">Responsable {{ forloop.counter }}</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label-cell">Nom :</td>
|
||||
<td class="value-cell">{{ guardian.last_name }}</td>
|
||||
<td class="label-cell">Prénom :</td>
|
||||
<td class="value-cell">{{ guardian.first_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">Adresse :</td>
|
||||
<td colspan="3" class="value-cell">{{ guardian.address }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">Né(e) le :</td>
|
||||
<td class="value-cell">{{ guardian.birth_date }}</td>
|
||||
<td class="label-cell">Email :</td>
|
||||
<td class="value-cell">{{ guardian.email }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">Téléphone :</td>
|
||||
<td class="value-cell phone">{{ guardian.phone|phone_format }}</td>
|
||||
<td class="label-cell">Profession :</td>
|
||||
<td class="value-cell">{{ guardian.profession }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Siblings Section -->
|
||||
<div class="section">
|
||||
<h2 class="section-title">FRATRIE</h2>
|
||||
{% for sibling in student.getSiblings %}
|
||||
<div class="subsection">
|
||||
<h3 class="subsection-title">Frère/Soeur {{ forloop.counter }}</h3>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label-cell">Nom :</td>
|
||||
<td class="value-cell">{{ sibling.last_name }}</td>
|
||||
<td class="label-cell">Prénom :</td>
|
||||
<td class="value-cell">{{ sibling.first_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">Né(e) le :</td>
|
||||
<td colspan="3" class="value-cell">{{ sibling.birth_date }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<!-- Payment Section -->
|
||||
<div class="section">
|
||||
<h2 class="section-title">MODALITÉS DE PAIEMENT</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="label-cell">Frais d'inscription :</td>
|
||||
<td class="value-cell">{{ student|getRegistrationPaymentMethod }} en {{ student|getRegistrationPaymentPlan }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label-cell">Frais de scolarité :</td>
|
||||
<td class="value-cell">{{ student|getTuitionPaymentMethod }} en {{ student|getTuitionPaymentPlan }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Signature Section -->
|
||||
<div class="signature">
|
||||
Fait le <span class="signature-text">{{ signatureDate }}</span> à <span class="signature-text">{{ signatureTime }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,8 +1,20 @@
|
||||
from Subscriptions.models import RegistrationForm, Student
|
||||
from School.models import PaymentModeType
|
||||
from School.models import PaymentModeType, PaymentPlanType
|
||||
from django import template
|
||||
import re
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def getRegistrationPaymentPlan(pk):
|
||||
registerForm = RegistrationForm.objects.get(student=pk)
|
||||
return PaymentPlanType(registerForm.registration_payment_plan).label
|
||||
|
||||
@register.filter
|
||||
def getTuitionPaymentPlan(pk):
|
||||
registerForm = RegistrationForm.objects.get(student=pk)
|
||||
return PaymentPlanType(registerForm.tuition_payment_plan).label
|
||||
|
||||
@register.filter
|
||||
def getRegistrationPaymentMethod(pk):
|
||||
registerForm = RegistrationForm.objects.get(student=pk)
|
||||
@ -21,4 +33,10 @@ def getStudentLevel(pk):
|
||||
@register.filter
|
||||
def getStudentGender(pk):
|
||||
registerForm = RegistrationForm.objects.get(student=pk)
|
||||
return Student.StudentGender(int(registerForm.student.gender)).label
|
||||
return Student.StudentGender(int(registerForm.student.gender)).label
|
||||
|
||||
@register.filter
|
||||
def phone_format(value):
|
||||
if value.startswith("+33"):
|
||||
value = value.replace("+33", "+33 ")
|
||||
return re.sub(r"(\d{2})", r"\1 ", value).strip()
|
||||
@ -132,7 +132,7 @@ def rfToPDF(registerForm, filename):
|
||||
}
|
||||
|
||||
# Générer le PDF
|
||||
pdf = renderers.render_to_pdf('pdfs/dossier_inscription.html', data)
|
||||
pdf = renderers.render_to_pdf('pdfs/fiche_eleve.html', data)
|
||||
if not pdf:
|
||||
raise ValueError("Erreur lors de la génération du PDF.")
|
||||
|
||||
|
||||
@ -885,9 +885,9 @@ export default function Page({ params: { locale } }) {
|
||||
{
|
||||
name: t('mainContactMail'),
|
||||
transform: (row) =>
|
||||
row.student.guardians && row.student.guardians.length > 0 && (
|
||||
row.student.guardians[0].associated_profile_email
|
||||
)
|
||||
row.student.guardians &&
|
||||
row.student.guardians.length > 0 &&
|
||||
row.student.guardians[0].associated_profile_email,
|
||||
},
|
||||
{
|
||||
name: t('phone'),
|
||||
|
||||
@ -93,22 +93,20 @@ export const updateProfileRoles = (id, data, csrfToken) => {
|
||||
};
|
||||
|
||||
export const deleteProfileRoles = async (id, csrfToken) => {
|
||||
const response = await fetch(
|
||||
`${BE_AUTH_PROFILES_ROLES_URL}/${id}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
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.';
|
||||
errorData?.error ||
|
||||
'Une erreur est survenue lors de la suppression du profil.';
|
||||
|
||||
// Jeter une erreur avec le message spécifique
|
||||
throw new Error(errorMessage);
|
||||
|
||||
@ -159,6 +159,7 @@ export default function PaymentMethodSelector({
|
||||
|
||||
<RadioList
|
||||
sectionLabel="Choisissez une option"
|
||||
required
|
||||
items={paymentPlansOptions
|
||||
.filter((option) =>
|
||||
tuitionPaymentPlans.some((plan) => plan.frequency === option.id)
|
||||
|
||||
@ -150,7 +150,7 @@ export default function ResponsableInputFields({
|
||||
name="prenomResponsable"
|
||||
type="text"
|
||||
label={t('firstname')}
|
||||
value={item.firstname || ''}
|
||||
value={item.first_name || ''}
|
||||
onChange={(event) => {
|
||||
onGuardiansChange(item.id, 'first_name', event.target.value);
|
||||
}}
|
||||
|
||||
@ -11,7 +11,6 @@ export default function SiblingInputFields({
|
||||
errors,
|
||||
setIsPageValid,
|
||||
}) {
|
||||
|
||||
const getError = (index, field) => {
|
||||
return errors[index]?.[field]?.[0];
|
||||
};
|
||||
@ -43,7 +42,7 @@ export default function SiblingInputFields({
|
||||
}
|
||||
return; // Sortir pour éviter de continuer l'exécution inutilement
|
||||
}
|
||||
|
||||
|
||||
// Synchroniser siblings avec formData uniquement si nécessaire
|
||||
setFormData((prevFormData) => {
|
||||
if (JSON.stringify(prevFormData.siblings) !== JSON.stringify(siblings)) {
|
||||
@ -54,14 +53,14 @@ export default function SiblingInputFields({
|
||||
}
|
||||
return prevFormData; // Évitez une mise à jour inutile
|
||||
});
|
||||
|
||||
|
||||
// Valider les siblings
|
||||
const isValid = siblings.every((sibling, index) => {
|
||||
return !Object.keys(sibling).some(
|
||||
(field) => getLocalError(index, field) !== ''
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
setIsPageValid(isValid);
|
||||
}, [siblings, getLocalError, setFormData, setIsPageValid]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user