feat(#158): front — attach/detach foyer (un seul appel API).
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
93912d1374
commit
d247867fa0
@ -1277,18 +1277,16 @@ class _AdminChildDetailModalState extends State<AdminChildDetailModal> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Édition orphelin (#157) : rattache immédiatement au foyer.
|
// Édition orphelin (#157/#158) : un seul attach — le back propage au foyer.
|
||||||
final enfantId = widget.enfant?.id;
|
final enfantId = widget.enfant?.id;
|
||||||
if (enfantId == null || enfantId.isEmpty) return;
|
if (enfantId == null || enfantId.isEmpty) return;
|
||||||
|
|
||||||
setState(() => _saving = true);
|
setState(() => _saving = true);
|
||||||
try {
|
try {
|
||||||
for (final parentId in selected.parentUserIds) {
|
await UserService.attachEnfantToParent(
|
||||||
await UserService.attachEnfantToParent(
|
parentUserId: selected.pivotParentUserId,
|
||||||
parentUserId: parentId,
|
enfantId: enfantId,
|
||||||
enfantId: enfantId,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
final refreshed = await UserService.getEnfant(enfantId);
|
final refreshed = await UserService.getEnfant(enfantId);
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|||||||
@ -283,7 +283,7 @@ class _AdminParentEditModalState extends State<AdminParentEditModal> {
|
|||||||
builder: (ctx) => AlertDialog(
|
builder: (ctx) => AlertDialog(
|
||||||
title: const Text('Détacher l\'enfant'),
|
title: const Text('Détacher l\'enfant'),
|
||||||
content: Text(
|
content: Text(
|
||||||
'Retirer ${child.fullName} de la fiche de ce parent ?',
|
'Retirer ${child.fullName} du foyer (tous les responsables) ?',
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
@ -308,8 +308,9 @@ class _AdminParentEditModalState extends State<AdminParentEditModal> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
await _reloadChildren();
|
await _reloadChildren();
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
widget.onSaved?.call();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Enfant détaché')),
|
const SnackBar(content: Text('Enfant détaché du foyer')),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
@ -336,8 +337,9 @@ class _AdminParentEditModalState extends State<AdminParentEditModal> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
await _reloadChildren();
|
await _reloadChildren();
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
widget.onSaved?.call();
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('Enfant rattaché')),
|
const SnackBar(content: Text('Enfant rattaché au foyer')),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user