feat(#147): modale de sélection d'AM depuis la fiche enfant.
Réutilise AdminSelectListModal avec filtre Libre, cartes saturées en rouge, avertissement + lien fiche AM, et recalcul des places à chaque rattachement. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:p_tits_pas/utils/enfant_status_utils.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/common/admin_am_edit_modal.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/common/admin_am_photo_frame.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/common/admin_parent_edit_modal.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/common/admin_select_am_modal.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/common/validation_detail_section.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/validation_modal_theme.dart';
|
||||
import 'package:p_tits_pas/widgets/common/auth_network_image.dart';
|
||||
@@ -399,49 +400,25 @@ class _AdminChildDetailModalState extends State<AdminChildDetailModal> {
|
||||
}
|
||||
|
||||
Future<void> _attachAm() async {
|
||||
List<AssistanteMaternelleModel> all;
|
||||
try {
|
||||
all = await UserService.getAssistantesMaternelles();
|
||||
} catch (e) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(e.toString().replaceFirst('Exception: ', ''))),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_linkedAm != null && !_isSansGarde) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Détachez l\'assistante actuelle avant d\'en choisir une autre'),
|
||||
content: Text(
|
||||
'Détachez l\'assistante actuelle avant d\'en choisir une autre',
|
||||
),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (all.isEmpty) {
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('Aucune assistante maternelle disponible')),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mounted) return;
|
||||
final selected = await showDialog<AssistanteMaternelleModel>(
|
||||
context: context,
|
||||
builder: (ctx) => SimpleDialog(
|
||||
title: const Text('Choisir une assistante maternelle'),
|
||||
children: all
|
||||
.map(
|
||||
(am) => SimpleDialogOption(
|
||||
onPressed: () => Navigator.pop(ctx, am),
|
||||
child: Text(am.user.fullName),
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
final selected = await AdminSelectAmModal.show(
|
||||
context,
|
||||
excludeIds: {
|
||||
if (_linkedAm != null) _linkedAm!.user.id,
|
||||
},
|
||||
title: 'Choisir une assistante maternelle',
|
||||
);
|
||||
if (selected == null || !mounted) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user