feat(dashboard-admin): connect admin dashboard to real API data (Ticket #92)
- Frontend:
- Create UserService to handle user-related API calls (gestionnaires, parents, AMs, admins)
- Update AdminDashboardScreen to use dynamic widgets
- Implement dynamic management widgets:
- GestionnaireManagementWidget
- ParentManagementWidget
- AssistanteMaternelleManagementWidget
- AdminManagementWidget
- Add data models: ParentModel, AssistanteMaternelleModel
- Update AppUser model
- Update ApiConfig
- Backend:
- Update controllers (Parents, AMs, Gestionnaires, Users) to allow ADMINISTRATEUR role to list users
- Note: Gestionnaires endpoint is currently bypassed in frontend (using /users filter) due to module import issue (documented in docs/92_NOTE-BACKEND-GESTIONNAIRES.md)
- Docs:
- Add note about backend fix for Gestionnaires module
- Update .cursorrules to forbid worktrees
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import 'package:p_tits_pas/models/user.dart';
|
||||
|
||||
class AssistanteMaternelleModel {
|
||||
final AppUser user;
|
||||
final String? approvalNumber;
|
||||
final String? residenceCity;
|
||||
final int? maxChildren;
|
||||
final int? placesAvailable;
|
||||
|
||||
AssistanteMaternelleModel({
|
||||
required this.user,
|
||||
this.approvalNumber,
|
||||
this.residenceCity,
|
||||
this.maxChildren,
|
||||
this.placesAvailable,
|
||||
});
|
||||
|
||||
factory AssistanteMaternelleModel.fromJson(Map<String, dynamic> json) {
|
||||
final userJson = json['user'] ?? json;
|
||||
final user = AppUser.fromJson(userJson);
|
||||
|
||||
return AssistanteMaternelleModel(
|
||||
user: user,
|
||||
approvalNumber: json['numero_agrement'] as String?,
|
||||
residenceCity: json['ville_residence'] as String?,
|
||||
maxChildren: json['nb_max_enfants'] as int?,
|
||||
placesAvailable: json['place_disponible'] as int?,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:p_tits_pas/models/user.dart';
|
||||
|
||||
class ParentModel {
|
||||
final AppUser user;
|
||||
final int childrenCount;
|
||||
|
||||
ParentModel({required this.user, this.childrenCount = 0});
|
||||
|
||||
factory ParentModel.fromJson(Map<String, dynamic> json) {
|
||||
final userJson = json['user'] ?? json;
|
||||
final user = AppUser.fromJson(userJson);
|
||||
final children = json['parentChildren'] as List?;
|
||||
return ParentModel(
|
||||
user: user,
|
||||
childrenCount: children?.length ?? 0,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,14 @@ class AppUser {
|
||||
final DateTime createdAt;
|
||||
final DateTime updatedAt;
|
||||
final bool changementMdpObligatoire;
|
||||
final String? nom;
|
||||
final String? prenom;
|
||||
final String? statut;
|
||||
final String? telephone;
|
||||
final String? photoUrl;
|
||||
final String? adresse;
|
||||
final String? ville;
|
||||
final String? codePostal;
|
||||
|
||||
AppUser({
|
||||
required this.id,
|
||||
@@ -13,6 +21,14 @@ class AppUser {
|
||||
required this.createdAt,
|
||||
required this.updatedAt,
|
||||
this.changementMdpObligatoire = false,
|
||||
this.nom,
|
||||
this.prenom,
|
||||
this.statut,
|
||||
this.telephone,
|
||||
this.photoUrl,
|
||||
this.adresse,
|
||||
this.ville,
|
||||
this.codePostal,
|
||||
});
|
||||
|
||||
factory AppUser.fromJson(Map<String, dynamic> json) {
|
||||
@@ -20,13 +36,26 @@ class AppUser {
|
||||
id: json['id'] as String,
|
||||
email: json['email'] as String,
|
||||
role: json['role'] as String,
|
||||
createdAt: json['createdAt'] != null
|
||||
? DateTime.parse(json['createdAt'] as String)
|
||||
: DateTime.now(),
|
||||
updatedAt: json['updatedAt'] != null
|
||||
? DateTime.parse(json['updatedAt'] as String)
|
||||
: DateTime.now(),
|
||||
changementMdpObligatoire: json['changement_mdp_obligatoire'] as bool? ?? false,
|
||||
createdAt: json['cree_le'] != null
|
||||
? DateTime.parse(json['cree_le'] as String)
|
||||
: (json['createdAt'] != null
|
||||
? DateTime.parse(json['createdAt'] as String)
|
||||
: DateTime.now()),
|
||||
updatedAt: json['modifie_le'] != null
|
||||
? DateTime.parse(json['modifie_le'] as String)
|
||||
: (json['updatedAt'] != null
|
||||
? DateTime.parse(json['updatedAt'] as String)
|
||||
: DateTime.now()),
|
||||
changementMdpObligatoire:
|
||||
json['changement_mdp_obligatoire'] as bool? ?? false,
|
||||
nom: json['nom'] as String?,
|
||||
prenom: json['prenom'] as String?,
|
||||
statut: json['statut'] as String?,
|
||||
telephone: json['telephone'] as String?,
|
||||
photoUrl: json['photo_url'] as String?,
|
||||
adresse: json['adresse'] as String?,
|
||||
ville: json['ville'] as String?,
|
||||
codePostal: json['code_postal'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,6 +67,16 @@ class AppUser {
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'updatedAt': updatedAt.toIso8601String(),
|
||||
'changement_mdp_obligatoire': changementMdpObligatoire,
|
||||
'nom': nom,
|
||||
'prenom': prenom,
|
||||
'statut': statut,
|
||||
'telephone': telephone,
|
||||
'photo_url': photoUrl,
|
||||
'adresse': adresse,
|
||||
'ville': ville,
|
||||
'code_postal': codePostal,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
String get fullName => '${prenom ?? ''} ${nom ?? ''}'.trim();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user