fix: Permettre l'activation des comptes élèves de moins de 15 ans créés par l'admin
Lorsqu'un admin créait un élève de moins de 15 ans avec une date de naissance, le compte ne pouvait pas être activé car le consentement parental RGPD n'avait jamais été enregistré — aucun mécanisme ne le permettait dans le parcours admin. Ajout d'une case « Consentement parental obtenu » dans le formulaire de création d'élève, affichée conditionnellement quand la date de naissance indique un âge < 15 ans. L'admin confirme que l'établissement a recueilli le consentement, qui est alors enregistré côté backend lors de la création du compte.
This commit is contained in:
@@ -39,11 +39,24 @@
|
||||
let newClassId = $state('');
|
||||
let newDateNaissance = $state('');
|
||||
let newStudentNumber = $state('');
|
||||
let newParentalConsent = $state(false);
|
||||
let isSubmitting = $state(false);
|
||||
let duplicateWarning = $state<string | null>(null);
|
||||
let duplicateConfirmed = $state(false);
|
||||
let createAnother = $state(false);
|
||||
|
||||
let needsParentalConsent = $derived(() => {
|
||||
if (!newDateNaissance) return false;
|
||||
const birth = new Date(newDateNaissance + 'T00:00:00');
|
||||
const now = new Date();
|
||||
let age = now.getFullYear() - birth.getFullYear();
|
||||
const monthDiff = now.getMonth() - birth.getMonth();
|
||||
if (monthDiff < 0 || (monthDiff === 0 && now.getDate() < birth.getDate())) {
|
||||
age--;
|
||||
}
|
||||
return age < 15;
|
||||
});
|
||||
|
||||
// Change class modal state
|
||||
let showChangeClassModal = $state(false);
|
||||
let changeClassTarget = $state<Student | null>(null);
|
||||
@@ -176,6 +189,7 @@
|
||||
newClassId = '';
|
||||
newDateNaissance = '';
|
||||
newStudentNumber = '';
|
||||
newParentalConsent = false;
|
||||
duplicateWarning = null;
|
||||
duplicateConfirmed = false;
|
||||
createAnother = false;
|
||||
@@ -224,6 +238,7 @@
|
||||
|
||||
async function handleCreateStudent() {
|
||||
if (!newFirstName.trim() || !newLastName.trim() || !newClassId) return;
|
||||
if (needsParentalConsent() && !newParentalConsent) return;
|
||||
|
||||
if (await checkDuplicate()) return;
|
||||
|
||||
@@ -236,7 +251,8 @@
|
||||
classId: newClassId,
|
||||
email: newEmail.trim() ? newEmail.trim().toLowerCase() : undefined,
|
||||
dateNaissance: newDateNaissance || undefined,
|
||||
studentNumber: newStudentNumber.trim() || undefined
|
||||
studentNumber: newStudentNumber.trim() || undefined,
|
||||
parentalConsent: newParentalConsent || undefined
|
||||
});
|
||||
|
||||
// Optimistic update: only add to list if matching current filters
|
||||
@@ -375,7 +391,8 @@
|
||||
newLastName.trim() !== '' &&
|
||||
newClassId !== '' &&
|
||||
!isSubmitting &&
|
||||
(!newStudentNumber.trim() || isValidINE(newStudentNumber.trim()))
|
||||
(!newStudentNumber.trim() || isValidINE(newStudentNumber.trim())) &&
|
||||
(!needsParentalConsent() || newParentalConsent)
|
||||
);
|
||||
</script>
|
||||
|
||||
@@ -609,6 +626,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if needsParentalConsent()}
|
||||
<div class="consent-notice">
|
||||
<label class="consent-label">
|
||||
<input type="checkbox" bind:checked={newParentalConsent} />
|
||||
<span>Consentement parental obtenu</span>
|
||||
</label>
|
||||
<span class="field-hint">
|
||||
Obligatoire pour les élèves de moins de 15 ans (RGPD).
|
||||
Confirmez que l'établissement a recueilli le consentement parental.
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if duplicateWarning}
|
||||
<div class="duplicate-warning">
|
||||
<p>{duplicateWarning}</p>
|
||||
@@ -1160,6 +1190,33 @@
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.consent-notice {
|
||||
padding: 0.75rem;
|
||||
background: #fef3c7;
|
||||
border: 1px solid #fcd34d;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.consent-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-weight: 500;
|
||||
color: #92400e;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.consent-label input[type='checkbox'] {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
accent-color: #f59e0b;
|
||||
}
|
||||
|
||||
.consent-notice .field-hint {
|
||||
margin-left: 1.5rem;
|
||||
color: #92400e;
|
||||
}
|
||||
|
||||
.field-error {
|
||||
display: block;
|
||||
margin-top: 0.25rem;
|
||||
|
||||
Reference in New Issue
Block a user