fix(front): refus famille en un seul appel API (#110)
Le back propage le refus et les mails aux co-parents ; évite la 2e requête en erreur. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
9eb62ddd13
commit
65f10e9ca6
@ -711,13 +711,11 @@ class _ValidationFamilyWizardState extends State<ValidationFamilyWizard> {
|
||||
);
|
||||
}
|
||||
|
||||
/// Refuse chaque parent encore `en_attente` (même commentaire, e-mail reprise par compte). Ticket #110.
|
||||
/// Un seul appel : le back refuse tout le dossier famille (co-parents + mails). Ticket #110.
|
||||
Future<void> _refuserEnvoyer(String comment) async {
|
||||
if (_submitting) return;
|
||||
final pending = widget.dossier.parents
|
||||
.where((p) => p.statut == 'en_attente' && p.id.trim().isNotEmpty)
|
||||
.toList();
|
||||
if (pending.isEmpty) {
|
||||
final parentId = _firstParentId?.trim();
|
||||
if (parentId == null || parentId.isEmpty || !_isEnAttente) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
@ -729,13 +727,13 @@ class _ValidationFamilyWizardState extends State<ValidationFamilyWizard> {
|
||||
}
|
||||
setState(() => _submitting = true);
|
||||
try {
|
||||
for (final p in pending) {
|
||||
await UserService.refuseUser(p.id, comment: comment);
|
||||
}
|
||||
await UserService.refuseUser(parentId, comment: comment);
|
||||
if (!mounted) return;
|
||||
final n = pending.length;
|
||||
final msg = n > 1
|
||||
? 'Refus enregistré pour $n comptes. Un e-mail de reprise a été envoyé à chacun.'
|
||||
final nbEnAttente = widget.dossier.parents
|
||||
.where((p) => p.statut == 'en_attente')
|
||||
.length;
|
||||
final msg = nbEnAttente > 1
|
||||
? 'Refus enregistré. Un e-mail de reprise a été envoyé à chaque parent du dossier.'
|
||||
: 'Refus enregistré. Un e-mail avec le lien de reprise a été envoyé.';
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user