fix(front): images validation dossier, traces debug, baseUrl via Env

- ApiConfig.baseUrl dérivé de Env.apiBaseUrl (alignement API / origine médias).
- AuthNetworkImage : uploads publics sans Bearer (CORS web) ; log erreurs en debug.
- debugPrint kDebugMode : GET dossier, EnfantDossier.fromJson, absoluteMediaUrl, carte enfant.
- ParentDossier id depuis user_id ; fallbacks présentation / photo.

Made-with: Cursor
This commit is contained in:
2026-04-11 17:08:34 +02:00
parent 09289882d0
commit 3bfdadd301
6 changed files with 240 additions and 26 deletions
+30 -3
View File
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:p_tits_pas/models/user.dart';
/// Réponse unifiée GET /dossiers/:numeroDossier. Ticket #119, #107.
@@ -107,7 +108,12 @@ class DossierFamille {
numeroDossier: json['numero_dossier']?.toString(),
parents: parentsList,
enfants: enfantsList,
presentation: (json['texte_motivation'] ?? json['presentation'])?.toString(),
presentation: (json['texte_motivation'] ??
json['presentation'] ??
json['presentation_dossier'] ??
json['texteMotivation'] ??
json['presentationDossier'])
?.toString(),
);
}
@@ -194,7 +200,27 @@ class EnfantDossier {
String get fullName => '${firstName ?? ''} ${lastName ?? ''}'.trim();
static String? _optionalPhotoUrl(dynamic v) {
if (v == null) return null;
if (v is String) {
final s = v.trim();
return s.isEmpty ? null : s;
}
final s = v.toString().trim();
return s.isEmpty ? null : s;
}
factory EnfantDossier.fromJson(Map<String, dynamic> json) {
final rawPhoto = json['photo_url'] ?? json['photoUrl'];
final resolvedPhoto = _optionalPhotoUrl(rawPhoto);
if (kDebugMode) {
debugPrint(
'[PetitsPas/dossier] EnfantDossier.fromJson id=${json['id']} '
'prénom=${json['first_name'] ?? json['prenom']} | '
'photo_url brute=$rawPhoto (${rawPhoto?.runtimeType}) → '
'résolu=${resolvedPhoto ?? ""}',
);
}
return EnfantDossier(
id: json['id']?.toString() ?? '',
firstName: (json['first_name'] ?? json['prenom'])?.toString(),
@@ -203,8 +229,9 @@ class EnfantDossier {
gender: (json['gender'] ?? json['genre'])?.toString(),
status: json['status']?.toString(),
dueDate: json['due_date']?.toString(),
photoUrl: (json['photo_url'] ?? json['photoUrl'])?.toString(),
consentPhoto: json['consent_photo'] == true,
photoUrl: resolvedPhoto,
consentPhoto:
json['consent_photo'] == true || json['consentPhoto'] == true,
);
}
}