feat(front): câbler PATCH refus utilisateur depuis wizards validation (#110)
- UserService.refuseUser → /users/:id/refuser - AM + famille : envoi motifs, onSuccess + refresh liste - Famille : refus séquentiel pour chaque parent en_attente - ValidationRefusForm : état isSubmitting (UX) Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -480,15 +480,12 @@ class _ValidationAmWizardState extends State<ValidationAmWizard> {
|
||||
children: [
|
||||
Expanded(
|
||||
child: ValidationRefusForm(
|
||||
isSubmitting: _submitting,
|
||||
onCancel: widget.onClose,
|
||||
onPrevious: () => setState(() => _showRefusForm = false),
|
||||
onSubmit: (comment) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Refus (à brancher sur l’API refus)')),
|
||||
);
|
||||
widget.onClose();
|
||||
if (comment == null || comment.trim().isEmpty) return;
|
||||
_refuserEnvoyer(comment.trim());
|
||||
},
|
||||
),
|
||||
),
|
||||
@@ -496,4 +493,26 @@ class _ValidationAmWizardState extends State<ValidationAmWizard> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _refuserEnvoyer(String comment) async {
|
||||
if (_submitting) return;
|
||||
setState(() => _submitting = true);
|
||||
try {
|
||||
await UserService.refuseUser(widget.dossier.user.id, comment: comment);
|
||||
if (!mounted) return;
|
||||
widget.onSuccess();
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(e is Exception
|
||||
? e.toString().replaceFirst('Exception: ', '')
|
||||
: 'Erreur'),
|
||||
backgroundColor: Colors.red.shade700,
|
||||
),
|
||||
);
|
||||
} finally {
|
||||
if (mounted) setState(() => _submitting = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user