fix(#170): brancher l’API couples-garde AM et unifier le bandeau
Évite le 403 en appelant /assistantes-maternelles/me/couples-garde, parse parents[], et affiche « Prénom1 et Prénom2 » sans vignette. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -37,7 +37,7 @@ class CoupleSelectorBandeau extends StatelessWidget {
|
||||
|
||||
CoupleGarde? get _selected {
|
||||
if (couples.isEmpty) return null;
|
||||
if (selectedCoupleId != null) {
|
||||
if (selectedCoupleId != null) {
|
||||
for (final c in couples) {
|
||||
if (c.id == selectedCoupleId) return c;
|
||||
}
|
||||
@@ -133,17 +133,46 @@ class _CoupleCard extends StatelessWidget {
|
||||
required this.colorIndex,
|
||||
});
|
||||
|
||||
/// Libellé parents côté AM : « Sophie » ou « Thomas et Claire ».
|
||||
static String _parentsLabel(List<CoupleMembre> parents) {
|
||||
if (parents.isEmpty) return 'Parents';
|
||||
String prenomOf(CoupleMembre p) {
|
||||
final prenom = (p.prenom ?? '').trim();
|
||||
if (prenom.isNotEmpty) return prenom;
|
||||
return p.displayName(fallback: 'Parent');
|
||||
}
|
||||
if (parents.length == 1) return prenomOf(parents.first);
|
||||
return '${prenomOf(parents[0])} et ${prenomOf(parents[1])}';
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// Parent mode: enfant | AM
|
||||
// AM mode: enfant | parent(s)
|
||||
// Parent mode: enfant | AM (photo + prénom)
|
||||
// AM mode: enfant | parent(s) — texte seul, pas de vignette parent
|
||||
final isParentMode = mode == CoupleBandeauMode.parent;
|
||||
final fallbackRoleIcon = isParentMode ? Icons.volunteer_activism : Icons.person_outline;
|
||||
final fallbackRoleName = isParentMode ? 'Nounou' : 'Parent';
|
||||
|
||||
// TODO: In AM mode, we should ideally display "parent1+parent2 empilés" or centered.
|
||||
// For now, CoupleGarde only gives us `am` (which in AM mode might just represent one parent, or the system needs to feed both parents here).
|
||||
// Assuming backend will populate `am` field with the parent data when called by AM.
|
||||
|
||||
Widget amOrParentsWidget;
|
||||
|
||||
if (isParentMode) {
|
||||
amOrParentsWidget = _MembreTile(
|
||||
photoUrl: couple.am?.photoUrl,
|
||||
name: (couple.am?.prenom != null && couple.am!.prenom!.isNotEmpty)
|
||||
? couple.am!.prenom!
|
||||
: (couple.am?.displayName(fallback: 'Nounou') ?? 'Nounou'),
|
||||
fallbackIcon: Icons.volunteer_activism,
|
||||
);
|
||||
} else {
|
||||
amOrParentsWidget = Text(
|
||||
_parentsLabel(couple.parents),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: GoogleFonts.merienda(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: QuotidienTheme.ink,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
height: 90,
|
||||
@@ -181,13 +210,7 @@ class _CoupleCard extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
child: _MembreTile(
|
||||
photoUrl: couple.am.photoUrl,
|
||||
name: (couple.am.prenom != null && couple.am.prenom!.isNotEmpty)
|
||||
? couple.am.prenom!
|
||||
: couple.am.displayName(fallback: fallbackRoleName),
|
||||
fallbackIcon: fallbackRoleIcon,
|
||||
),
|
||||
child: amOrParentsWidget,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
Reference in New Issue
Block a user