feat(#112): reprise après refus via lien e-mail (/reprise?token=)
Branche le flux front : chargement du dossier, session reprise, wizards parent/AM préremplis et resoumission via reprise-resoumettre. 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,
|
||||
|
||||
@@ -8,6 +8,7 @@ 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 '../../widgets/hover_relief_widget.dart';
|
||||
import '../../widgets/image_button.dart';
|
||||
import '../../widgets/custom_navigation_button.dart';
|
||||
@@ -27,7 +28,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 +57,22 @@ class _AmRegisterStep4ScreenState extends State<AmRegisterStep4Screen> {
|
||||
}
|
||||
setState(() => _isSubmitting = true);
|
||||
try {
|
||||
if (RepriseSession.isActive) {
|
||||
await AuthService.resoumettreReprise(
|
||||
token: RepriseSession.token!,
|
||||
prenom: registrationData.firstName,
|
||||
nom: registrationData.lastName,
|
||||
telephone: registrationData.phone,
|
||||
adresse: registrationData.streetAddress,
|
||||
ville: registrationData.city,
|
||||
codePostal: registrationData.postalCode,
|
||||
photoUrl: RepriseSession.photoUrl,
|
||||
);
|
||||
RepriseSession.clear();
|
||||
if (!mounted) return;
|
||||
_showRepriseConfirmationModal(context);
|
||||
return;
|
||||
}
|
||||
await AuthService.registerAM(registrationData);
|
||||
if (!mounted) return;
|
||||
_showConfirmationModal(context);
|
||||
@@ -244,6 +275,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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -14,6 +14,7 @@ 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';
|
||||
|
||||
class ParentRegisterStep5Screen extends StatefulWidget {
|
||||
const ParentRegisterStep5Screen({super.key});
|
||||
@@ -27,8 +28,39 @@ 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 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!;
|
||||
final p = data.parent1;
|
||||
await AuthService.resoumettreReprise(
|
||||
token: token,
|
||||
prenom: p.firstName,
|
||||
nom: p.lastName,
|
||||
telephone: p.phone,
|
||||
adresse: p.address,
|
||||
ville: p.city,
|
||||
codePostal: p.postalCode,
|
||||
);
|
||||
RepriseSession.clear();
|
||||
if (!context.mounted) return;
|
||||
_showRepriseSuccessModal(context);
|
||||
return;
|
||||
}
|
||||
await AuthService.registerParent(data);
|
||||
if (!context.mounted) return;
|
||||
_showSuccessModal(context);
|
||||
@@ -279,6 +311,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