feat(#112): reprise après refus — dossier complet, email resoumission

- GET/PATCH reprise-dossier enrichis (parents, enfants, motivation, fiche AM)
- Front: lien mail, modale identify login, wizards préremplis, PATCH complet
- Email accusé resoumission aux parents avec n° de dossier
- Fixes préremplissage AM (dates, places, ValueKey étape 2)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-16 19:19:55 +02:00
co-authored by Cursor
parent c226c2fcdf
commit b99745e0fe
36 changed files with 2460 additions and 85 deletions
@@ -0,0 +1,168 @@
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../services/auth_service.dart';
import '../../utils/email_utils.dart';
import '../custom_app_text_field.dart';
/// Modale login : numéro de dossier + e-mail → token reprise (#112).
class RepriseIdentifyDialog extends StatefulWidget {
final String? initialEmail;
const RepriseIdentifyDialog({super.key, this.initialEmail});
@override
State<RepriseIdentifyDialog> createState() => _RepriseIdentifyDialogState();
}
class _RepriseIdentifyDialogState extends State<RepriseIdentifyDialog> {
final _formKey = GlobalKey<FormState>();
late final TextEditingController _numeroCtrl;
late final TextEditingController _emailCtrl;
bool _loading = false;
String? _error;
@override
void initState() {
super.initState();
_numeroCtrl = TextEditingController();
_emailCtrl = TextEditingController(text: widget.initialEmail ?? '');
}
@override
void dispose() {
_numeroCtrl.dispose();
_emailCtrl.dispose();
super.dispose();
}
String? _validateNumero(String? value) {
final v = value?.trim() ?? '';
if (v.isEmpty) {
return 'Indiquez votre numéro de dossier.';
}
return null;
}
String? _validateEmail(String? value) {
final v = value?.trim() ?? '';
if (v.isEmpty) {
return 'Indiquez votre adresse e-mail.';
}
if (!isValidEmailFormat(v)) {
return 'Ladresse e-mail nest pas valide.';
}
return null;
}
Future<void> _submit() async {
if (_loading) return;
setState(() => _error = null);
if (!(_formKey.currentState?.validate() ?? false)) return;
setState(() => _loading = true);
try {
final token = await AuthService.identifyReprise(
numeroDossier: _numeroCtrl.text,
email: _emailCtrl.text,
);
if (!mounted) return;
Navigator.of(context).pop(token);
} catch (e) {
if (!mounted) return;
setState(() {
_loading = false;
_error = e is Exception
? e.toString().replaceFirst('Exception: ', '')
: 'Impossible de retrouver votre dossier.';
});
}
}
@override
Widget build(BuildContext context) {
return AlertDialog(
title: Text(
'Reprendre mon dossier',
style: GoogleFonts.merienda(fontWeight: FontWeight.bold),
),
content: SizedBox(
width: 420,
child: Form(
key: _formKey,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'Saisissez le numéro de dossier et le-mail utilisés lors '
'de linscription (dossier refusé en attente de correction).',
style: GoogleFonts.merienda(fontSize: 13),
),
const SizedBox(height: 16),
CustomAppTextField(
controller: _numeroCtrl,
labelText: 'Numéro de dossier',
hintText: 'Ex. 2026-000021',
textInputAction: TextInputAction.next,
validator: _validateNumero,
style: CustomAppTextFieldStyle.lavande,
fieldHeight: 48,
fieldWidth: double.infinity,
),
const SizedBox(height: 12),
CustomAppTextField(
controller: _emailCtrl,
labelText: 'E-mail',
hintText: 'Votre adresse e-mail',
keyboardType: TextInputType.emailAddress,
autocorrect: false,
enableSuggestions: false,
inputFormatters: const [EmailMaxLengthFormatter()],
textInputAction: TextInputAction.done,
onFieldSubmitted: (_) => _submit(),
validator: _validateEmail,
style: CustomAppTextFieldStyle.lavande,
fieldHeight: 48,
fieldWidth: double.infinity,
),
if (_error != null) ...[
const SizedBox(height: 12),
Text(
_error!,
style: GoogleFonts.merienda(
fontSize: 12,
color: Colors.red.shade700,
),
),
],
],
),
),
),
actions: [
TextButton(
onPressed: _loading ? null : () => Navigator.of(context).pop(),
child: Text('Annuler', style: GoogleFonts.merienda()),
),
TextButton(
onPressed: _loading ? null : _submit,
child: _loading
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Text(
'Continuer',
style: GoogleFonts.merienda(
fontWeight: FontWeight.bold,
color: const Color(0xFF2D6A4F),
),
),
),
],
);
}
}
+17 -1
View File
@@ -1,4 +1,5 @@
import 'dart:math' as math;
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
@@ -20,7 +21,7 @@ bool _hasChildPhoto(ChildData c) {
return registrationPhotoSlotHasImage(
imageBytes: c.imageBytes,
imageFile: c.imageFile,
imagePathOrAsset: null,
imagePathOrAsset: c.existingPhotoUrl,
);
}
@@ -33,6 +34,20 @@ Widget _buildChildPhotoImage(ChildData c, {required BoxFit fit}) {
if (f != null) {
return kIsWeb ? Image.network(f.path, fit: fit) : Image.file(f, fit: fit);
}
final url = c.existingPhotoUrl?.trim();
if (url != null && url.isNotEmpty) {
if (url.startsWith('http://') || url.startsWith('https://')) {
return Image.network(url, fit: fit);
}
if (!kIsWeb) {
try {
final file = File(url);
if (file.existsSync()) {
return Image.file(file, fit: fit);
}
} catch (_) {}
}
}
return Image.asset('assets/images/photo.png', fit: BoxFit.contain);
}
@@ -221,6 +236,7 @@ class _ChildCardWidgetState extends State<ChildCardWidget> {
scaleFactor: scaleFactor,
imageBytes: widget.childData.imageBytes,
imageFile: widget.childData.imageFile,
imagePathOrAsset: widget.childData.existingPhotoUrl,
onTapPick: !config.isReadonly ? widget.onPickImage : null,
onClear: !config.isReadonly ? widget.onClearImage : null,
baseShadowColor: baseCardColorForShadow,
@@ -134,30 +134,7 @@ class _ProfessionalInfoFormScreenState extends State<ProfessionalInfoFormScreen>
@override
void initState() {
super.initState();
final data = widget.initialData;
if (data != null) {
_selectedDate = data.dateOfBirth;
_dateOfBirthController.text = data.dateOfBirth != null
? DateFormat('dd/MM/yyyy').format(data.dateOfBirth!)
: '';
_birthCityController.text = data.birthCity;
_birthCountryController.text = data.birthCountry;
final nirRaw = nirToRaw(data.nir);
_nirController.text = nirRaw.length == 15 ? formatNir(nirRaw) : data.nir;
_agrementController.text = data.agrementNumber;
_selectedAgreementDate = data.agreementDate;
_agreementDateController.text = data.agreementDate != null
? DateFormat('dd/MM/yyyy').format(data.agreementDate!)
: '';
_capacityController.text = data.capacity?.toString() ?? '';
_placesAvailableController.text = data.placesAvailable?.toString() ?? '';
_photoPathFramework = data.photoPath;
_photoFile = data.photoFile;
_photoBytes = data.photoBytes;
_photoFilename = data.photoFilename;
_photoConsent = data.photoConsent;
}
_applyInitialData(widget.initialData);
if (widget.mode == DisplayMode.editable) {
_birthCityFocus = FocusNode();
@@ -168,6 +145,51 @@ class _ProfessionalInfoFormScreenState extends State<ProfessionalInfoFormScreen>
}
}
@override
void didUpdateWidget(covariant ProfessionalInfoFormScreen oldWidget) {
super.didUpdateWidget(oldWidget);
final next = widget.initialData;
final prev = oldWidget.initialData;
if (next == null) return;
if (prev == null ||
prev.dateOfBirth != next.dateOfBirth ||
prev.agreementDate != next.agreementDate ||
prev.placesAvailable != next.placesAvailable ||
prev.capacity != next.capacity ||
prev.nir != next.nir ||
prev.birthCity != next.birthCity ||
prev.birthCountry != next.birthCountry ||
prev.agrementNumber != next.agrementNumber ||
prev.photoPath != next.photoPath ||
prev.photoConsent != next.photoConsent) {
_applyInitialData(next);
}
}
void _applyInitialData(ProfessionalInfoData? data) {
if (data == null) return;
_selectedDate = data.dateOfBirth;
_dateOfBirthController.text = data.dateOfBirth != null
? DateFormat('dd/MM/yyyy').format(data.dateOfBirth!)
: '';
_birthCityController.text = data.birthCity;
_birthCountryController.text = data.birthCountry;
final nirRaw = nirToRaw(data.nir);
_nirController.text = nirRaw.length == 15 ? formatNir(nirRaw) : data.nir;
_agrementController.text = data.agrementNumber;
_selectedAgreementDate = data.agreementDate;
_agreementDateController.text = data.agreementDate != null
? DateFormat('dd/MM/yyyy').format(data.agreementDate!)
: '';
_capacityController.text = data.capacity?.toString() ?? '';
_placesAvailableController.text = data.placesAvailable?.toString() ?? '';
_photoPathFramework = data.photoPath;
_photoFile = data.photoFile;
_photoBytes = data.photoBytes;
_photoFilename = data.photoFilename;
_photoConsent = data.photoConsent;
}
void _onBirthCityFocusChange() {
if (_birthCityFocus == null || _birthCityFocus!.hasFocus) return;
_applyPlaceNameFormat(_birthCityController);
@@ -71,6 +71,9 @@ class RegistrationPhotoSlot extends StatelessWidget {
if (p.startsWith('assets/')) {
return Image.asset(p, fit: fit);
}
if (p.startsWith('http://') || p.startsWith('https://')) {
return Image.network(p, fit: fit);
}
if (!kIsWeb) {
try {
final file = File(p);