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:
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../models/am_registration_data.dart';
|
||||
import '../../widgets/personal_info_form_screen.dart';
|
||||
import '../../services/reprise_session.dart';
|
||||
import '../../models/card_assets.dart';
|
||||
|
||||
class AmRegisterStep1Screen extends StatelessWidget {
|
||||
@@ -29,7 +30,7 @@ class AmRegisterStep1Screen extends StatelessWidget {
|
||||
cardColor: CardColorHorizontal.blue,
|
||||
initialData: initialData,
|
||||
minPersonNameLength: 2,
|
||||
previousRoute: '/register-choice',
|
||||
previousRoute: RepriseSession.isActive ? '/login' : '/register-choice',
|
||||
onSubmit: (data, {hasSecondPerson, sameAddress}) {
|
||||
registrationData.updateIdentityInfo(
|
||||
firstName: data.firstName,
|
||||
|
||||
@@ -11,45 +11,53 @@ class AmRegisterStep2Screen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final registrationData = Provider.of<AmRegistrationData>(context, listen: false);
|
||||
return Consumer<AmRegistrationData>(
|
||||
builder: (context, registrationData, _) {
|
||||
final initialData = ProfessionalInfoData(
|
||||
photoPath: registrationData.photoPath,
|
||||
photoBytes: registrationData.photoBytes,
|
||||
photoFilename: registrationData.photoFilename,
|
||||
photoConsent: registrationData.photoConsent,
|
||||
dateOfBirth: registrationData.dateOfBirth,
|
||||
birthCity: registrationData.birthCity,
|
||||
birthCountry: registrationData.birthCountry,
|
||||
nir: registrationData.nir,
|
||||
agrementNumber: registrationData.agrementNumber,
|
||||
agreementDate: registrationData.agreementDate,
|
||||
capacity: registrationData.capacity,
|
||||
placesAvailable: registrationData.placesAvailable,
|
||||
);
|
||||
|
||||
final initialData = ProfessionalInfoData(
|
||||
photoPath: registrationData.photoPath,
|
||||
photoBytes: registrationData.photoBytes,
|
||||
photoFilename: registrationData.photoFilename,
|
||||
photoConsent: registrationData.photoConsent,
|
||||
dateOfBirth: registrationData.dateOfBirth,
|
||||
birthCity: registrationData.birthCity,
|
||||
birthCountry: registrationData.birthCountry,
|
||||
nir: registrationData.nir,
|
||||
agrementNumber: registrationData.agrementNumber,
|
||||
agreementDate: registrationData.agreementDate,
|
||||
capacity: registrationData.capacity,
|
||||
placesAvailable: registrationData.placesAvailable,
|
||||
);
|
||||
|
||||
return ProfessionalInfoFormScreen(
|
||||
stepText: 'Étape 2/4',
|
||||
title: 'Vos informations professionnelles',
|
||||
cardColor: CardColorHorizontal.green,
|
||||
initialData: initialData,
|
||||
previousRoute: '/am-register-step1',
|
||||
onSubmit: (data) {
|
||||
registrationData.updateProfessionalInfo(
|
||||
photoPath: data.photoPath,
|
||||
photoBytes: data.photoBytes,
|
||||
photoFilename: data.photoFilename,
|
||||
photoConsent: data.photoConsent,
|
||||
dateOfBirth: data.dateOfBirth,
|
||||
birthCity: data.birthCity,
|
||||
birthCountry: data.birthCountry,
|
||||
nir: data.nir,
|
||||
agrementNumber: data.agrementNumber,
|
||||
agreementDate: data.agreementDate,
|
||||
capacity: data.capacity,
|
||||
placesAvailable: data.placesAvailable,
|
||||
return ProfessionalInfoFormScreen(
|
||||
key: ValueKey(
|
||||
'am-pro-${registrationData.dateOfBirth?.millisecondsSinceEpoch}'
|
||||
'-${registrationData.agreementDate?.millisecondsSinceEpoch}'
|
||||
'-${registrationData.placesAvailable}'
|
||||
'-${registrationData.nir}',
|
||||
),
|
||||
stepText: 'Étape 2/4',
|
||||
title: 'Vos informations professionnelles',
|
||||
cardColor: CardColorHorizontal.green,
|
||||
initialData: initialData,
|
||||
previousRoute: '/am-register-step1',
|
||||
onSubmit: (data) {
|
||||
registrationData.updateProfessionalInfo(
|
||||
photoPath: data.photoPath,
|
||||
photoBytes: data.photoBytes,
|
||||
photoFilename: data.photoFilename,
|
||||
photoConsent: data.photoConsent,
|
||||
dateOfBirth: data.dateOfBirth,
|
||||
birthCity: data.birthCity,
|
||||
birthCountry: data.birthCountry,
|
||||
nir: data.nir,
|
||||
agrementNumber: data.agrementNumber,
|
||||
agreementDate: data.agreementDate,
|
||||
capacity: data.capacity,
|
||||
placesAvailable: data.placesAvailable,
|
||||
);
|
||||
context.go('/am-register-step3');
|
||||
},
|
||||
);
|
||||
context.go('/am-register-step3');
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import '../../models/am_registration_data.dart';
|
||||
import '../../models/card_assets.dart';
|
||||
import '../../config/display_config.dart';
|
||||
import '../../services/auth_service.dart';
|
||||
import '../../services/reprise_session.dart';
|
||||
import '../../utils/reprise_payload.dart';
|
||||
import '../../widgets/hover_relief_widget.dart';
|
||||
import '../../widgets/image_button.dart';
|
||||
import '../../widgets/custom_navigation_button.dart';
|
||||
@@ -27,7 +29,21 @@ class _AmRegisterStep4ScreenState extends State<AmRegisterStep4Screen> {
|
||||
|
||||
Future<void> _submitAMRegistration(AmRegistrationData registrationData) async {
|
||||
if (_isSubmitting) return;
|
||||
if (!registrationData.isRegistrationComplete) {
|
||||
if (RepriseSession.isActive) {
|
||||
if (!registrationData.isRepriseSubmitReady) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'Vérifiez vos coordonnées et acceptez les conditions.',
|
||||
style: GoogleFonts.merienda(fontSize: 14),
|
||||
),
|
||||
backgroundColor: Colors.red.shade700,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
} else if (!registrationData.isRegistrationComplete) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
@@ -42,6 +58,19 @@ class _AmRegisterStep4ScreenState extends State<AmRegisterStep4Screen> {
|
||||
}
|
||||
setState(() => _isSubmitting = true);
|
||||
try {
|
||||
if (RepriseSession.isActive) {
|
||||
await AuthService.resoumettreReprise(
|
||||
await ReprisePayload.amPatch(
|
||||
registrationData,
|
||||
RepriseSession.token!,
|
||||
existingPhotoUrl: RepriseSession.photoUrlForApi,
|
||||
),
|
||||
);
|
||||
RepriseSession.clear();
|
||||
if (!mounted) return;
|
||||
_showRepriseConfirmationModal(context);
|
||||
return;
|
||||
}
|
||||
await AuthService.registerAM(registrationData);
|
||||
if (!mounted) return;
|
||||
_showConfirmationModal(context);
|
||||
@@ -244,6 +273,34 @@ class _AmRegisterStep4ScreenState extends State<AmRegisterStep4Screen> {
|
||||
);
|
||||
}
|
||||
|
||||
void _showRepriseConfirmationModal(BuildContext context) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Dossier resoumis',
|
||||
style: GoogleFonts.merienda(fontWeight: FontWeight.bold),
|
||||
),
|
||||
content: Text(
|
||||
'Vos modifications ont été enregistrées. Votre dossier est de nouveau en attente de validation.',
|
||||
style: GoogleFonts.merienda(fontSize: 14),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('OK', style: GoogleFonts.merienda(fontWeight: FontWeight.bold)),
|
||||
onPressed: () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
context.go('/login');
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showConfirmationModal(BuildContext context) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
|
||||
@@ -10,6 +10,7 @@ import '../../widgets/image_button.dart';
|
||||
import '../../widgets/custom_app_text_field.dart';
|
||||
import '../../services/auth_service.dart';
|
||||
import '../../widgets/auth/change_password_dialog.dart';
|
||||
import '../../widgets/auth/reprise_identify_dialog.dart';
|
||||
|
||||
class LoginScreen extends StatefulWidget {
|
||||
const LoginScreen({super.key});
|
||||
@@ -100,6 +101,31 @@ class _LoginPageState extends State<LoginScreen> {
|
||||
_handleLogin();
|
||||
}
|
||||
|
||||
Future<void> _openRepriseIdentify() async {
|
||||
final token = await showDialog<String>(
|
||||
context: context,
|
||||
builder: (ctx) => RepriseIdentifyDialog(
|
||||
initialEmail: _emailController.text.trim(),
|
||||
),
|
||||
);
|
||||
if (!mounted || token == null || token.isEmpty) return;
|
||||
context.go('/reprise?token=${Uri.encodeComponent(token)}');
|
||||
}
|
||||
|
||||
Widget _buildRepriseDossierLink({double fontSize = 14}) {
|
||||
return TextButton(
|
||||
onPressed: _isLoading ? null : _openRepriseIdentify,
|
||||
child: Text(
|
||||
'J’ai un numéro de dossier',
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: fontSize,
|
||||
color: const Color(0xFF2D6A4F),
|
||||
decoration: TextDecoration.underline,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Gère la connexion de l'utilisateur
|
||||
Future<void> _handleLogin() async {
|
||||
// Réinitialiser le message d'erreur
|
||||
@@ -384,6 +410,7 @@ class _LoginPageState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(child: _buildRepriseDossierLink()),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -640,6 +667,7 @@ class _LoginPageState extends State<LoginScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildRepriseDossierLink(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../models/user_registration_data.dart';
|
||||
import '../../widgets/personal_info_form_screen.dart';
|
||||
import '../../services/reprise_session.dart';
|
||||
import '../../models/card_assets.dart';
|
||||
|
||||
class ParentRegisterStep1Screen extends StatelessWidget {
|
||||
@@ -29,7 +30,7 @@ class ParentRegisterStep1Screen extends StatelessWidget {
|
||||
title: 'Informations du Parent Principal',
|
||||
cardColor: CardColorHorizontal.peach,
|
||||
initialData: initialData,
|
||||
previousRoute: '/register-choice',
|
||||
previousRoute: RepriseSession.isActive ? '/login' : '/register-choice',
|
||||
onSubmit: (data, {hasSecondPerson, sameAddress}) {
|
||||
registrationData.updateParent1(ParentData(
|
||||
firstName: data.firstName,
|
||||
|
||||
@@ -166,7 +166,11 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
||||
if (await f.exists()) file = f;
|
||||
} catch (_) {}
|
||||
}
|
||||
final updatedChild = oldChild.copyWith(imageBytes: bytes, imageFile: file);
|
||||
final updatedChild = oldChild.copyWith(
|
||||
imageBytes: bytes,
|
||||
imageFile: file,
|
||||
existingPhotoUrl: null,
|
||||
);
|
||||
registrationData.updateChild(childIndex, updatedChild);
|
||||
}
|
||||
}
|
||||
@@ -306,7 +310,7 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
||||
onClearImage: () => setState(() {
|
||||
final c = registrationData.children[index];
|
||||
registrationData.updateChild(
|
||||
index, c.copyWith(imageFile: null, imageBytes: null));
|
||||
index, c.copyWith(imageFile: null, imageBytes: null, existingPhotoUrl: null));
|
||||
}),
|
||||
onDateSelect: () => _selectDate(context, index, registrationData),
|
||||
onFirstNameChanged: (value) => setState(() {
|
||||
@@ -414,7 +418,7 @@ class _ParentRegisterStep3ScreenState extends State<ParentRegisterStep3Screen> {
|
||||
onClearImage: () => setState(() {
|
||||
final c = registrationData.children[index];
|
||||
registrationData.updateChild(
|
||||
index, c.copyWith(imageFile: null, imageBytes: null));
|
||||
index, c.copyWith(imageFile: null, imageBytes: null, existingPhotoUrl: null));
|
||||
}),
|
||||
onDateSelect: () => _selectDate(context, index, registrationData),
|
||||
onFirstNameChanged: (value) => setState(() {
|
||||
|
||||
@@ -14,6 +14,8 @@ import '../../widgets/personal_info_form_screen.dart';
|
||||
import '../../widgets/child_card_widget.dart';
|
||||
import '../../widgets/presentation_form_screen.dart';
|
||||
import '../../services/auth_service.dart';
|
||||
import '../../services/reprise_session.dart';
|
||||
import '../../utils/reprise_payload.dart';
|
||||
|
||||
class ParentRegisterStep5Screen extends StatefulWidget {
|
||||
const ParentRegisterStep5Screen({super.key});
|
||||
@@ -27,8 +29,32 @@ class _ParentRegisterStep5ScreenState extends State<ParentRegisterStep5Screen> {
|
||||
|
||||
Future<void> _submitRegistration(BuildContext context, UserRegistrationData data) async {
|
||||
if (_isSubmitting) return;
|
||||
if (RepriseSession.isActive) {
|
||||
if (!data.isRepriseSubmitReady) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'Vérifiez vos coordonnées, les enfants et acceptez les conditions.',
|
||||
style: GoogleFonts.merienda(fontSize: 14),
|
||||
),
|
||||
backgroundColor: Colors.red.shade700,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setState(() => _isSubmitting = true);
|
||||
try {
|
||||
if (RepriseSession.isActive) {
|
||||
final token = RepriseSession.token!;
|
||||
await AuthService.resoumettreReprise(
|
||||
ReprisePayload.parentPatch(data, token),
|
||||
);
|
||||
RepriseSession.clear();
|
||||
if (!context.mounted) return;
|
||||
_showRepriseSuccessModal(context);
|
||||
return;
|
||||
}
|
||||
await AuthService.registerParent(data);
|
||||
if (!context.mounted) return;
|
||||
_showSuccessModal(context);
|
||||
@@ -279,6 +305,34 @@ class _ParentRegisterStep5ScreenState extends State<ParentRegisterStep5Screen> {
|
||||
);
|
||||
}
|
||||
|
||||
void _showRepriseSuccessModal(BuildContext context) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (BuildContext dialogContext) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Dossier resoumis',
|
||||
style: GoogleFonts.merienda(fontWeight: FontWeight.bold),
|
||||
),
|
||||
content: Text(
|
||||
'Vos modifications ont été enregistrées. Votre dossier est de nouveau en attente de validation.',
|
||||
style: GoogleFonts.merienda(fontSize: 14),
|
||||
),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text('OK', style: GoogleFonts.merienda(fontWeight: FontWeight.bold)),
|
||||
onPressed: () {
|
||||
Navigator.of(dialogContext).pop();
|
||||
context.go('/login');
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void _showSuccessModal(BuildContext context) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
import '../../config/app_router.dart';
|
||||
import '../../services/auth_service.dart';
|
||||
import '../../services/reprise_session.dart';
|
||||
|
||||
/// Point d'entrée `/reprise?token=` — charge le dossier et ouvre le wizard (#112).
|
||||
class RepriseEntryScreen extends StatefulWidget {
|
||||
final String? token;
|
||||
|
||||
const RepriseEntryScreen({super.key, this.token});
|
||||
|
||||
@override
|
||||
State<RepriseEntryScreen> createState() => _RepriseEntryScreenState();
|
||||
}
|
||||
|
||||
class _RepriseEntryScreenState extends State<RepriseEntryScreen> {
|
||||
bool _loading = true;
|
||||
String? _error;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _load());
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
final token = widget.token?.trim() ?? '';
|
||||
if (token.isEmpty) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'Lien invalide ou expiré.';
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_loading = true;
|
||||
_error = null;
|
||||
});
|
||||
|
||||
try {
|
||||
final dossier = await AuthService.getRepriseDossier(token);
|
||||
if (!mounted) return;
|
||||
|
||||
RepriseSession.clear();
|
||||
RepriseSession.start(token: token, dossier: dossier);
|
||||
|
||||
if (dossier.isParent) {
|
||||
RepriseSession.applyToParent(userRegistrationDataNotifier, dossier);
|
||||
context.go('/parent-register-step1');
|
||||
return;
|
||||
}
|
||||
if (dossier.isAm) {
|
||||
RepriseSession.applyToAm(amRegistrationDataNotifier, dossier);
|
||||
context.go('/am-register-step1');
|
||||
return;
|
||||
}
|
||||
|
||||
RepriseSession.clear();
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'Type de dossier non pris en charge pour la reprise.';
|
||||
});
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
RepriseSession.clear();
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = e is Exception
|
||||
? e.toString().replaceFirst('Exception: ', '')
|
||||
: 'Impossible de charger votre dossier.';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: Stack(
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: Image.asset(
|
||||
'assets/images/paper2.png',
|
||||
fit: BoxFit.cover,
|
||||
repeat: ImageRepeat.repeat,
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 420),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: _buildBody(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBody() {
|
||||
if (_loading) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'Chargement de votre dossier…',
|
||||
style: GoogleFonts.merienda(fontSize: 16),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
final err = _error ?? 'Lien invalide ou expiré.';
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.error_outline, size: 48, color: Colors.red.shade700),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Reprise du dossier',
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
err,
|
||||
style: GoogleFonts.merienda(fontSize: 14, color: Colors.black87),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
TextButton(
|
||||
onPressed: () => context.go('/login'),
|
||||
child: Text(
|
||||
'Retour à la connexion',
|
||||
style: GoogleFonts.merienda(
|
||||
decoration: TextDecoration.underline,
|
||||
color: const Color(0xFF2D6A4F),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user