Author SHA1 Message Date
Hanim bbbff60a7a resolve conflict 2025-09-15 13:40:30 +02:00
Hanim 050087359c feat: add Parent managment with admin dashbord 2025-09-15 13:28:20 +02:00
Hanim 68adc027cb Add modif of compile 2025-09-12 16:28:55 +02:00
Hanim 05b2380181 add corection 2025-09-12 16:25:20 +02:00
Hanim c332eb3d86 add modification version http 2025-09-12 16:11:53 +02:00
hmoussa a8f174a663 Merge pull request 'dev' (#67) from dev into master
Reviewed-on: #67
2025-09-12 13:28:04 +00:00
hmoussa 61554c5edc Merge pull request 'Add routes navigation login and admin dashboard' (#66) from feature/FRONT-07 into dev
Reviewed-on: #66
2025-09-12 13:27:29 +00:00
hmoussa ad9ca5c5b5 Merge pull request 'dev' (#63) from dev into master
Reviewed-on: #63
2025-09-01 10:05:42 +00:00
9 changed files with 477 additions and 154 deletions
@@ -20,11 +20,6 @@ public final class GeneratedPluginRegistrant {
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "Error registering plugin flutter_plugin_android_lifecycle, io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin", e); Log.e(TAG, "Error registering plugin flutter_plugin_android_lifecycle, io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin", e);
} }
try {
flutterEngine.getPlugins().add(new com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin());
} catch (Exception e) {
Log.e(TAG, "Error registering plugin flutter_secure_storage, com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin", e);
}
try { try {
flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin()); flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin());
} catch (Exception e) { } catch (Exception e) {
+6 -5
View File
@@ -140,7 +140,8 @@ class _LoginPageState extends State<LoginPage> {
body: LayoutBuilder( body: LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
// Version desktop (web) // Version desktop (web)
if (kIsWeb) {
// if (kIsWeb) {
final w = constraints.maxWidth; final w = constraints.maxWidth;
final h = constraints.maxHeight; final h = constraints.maxHeight;
@@ -346,12 +347,12 @@ class _LoginPageState extends State<LoginPage> {
); );
}, },
); );
} // }
// Version mobile (à implémenter) // Version mobile (à implémenter)
return const Center( // return const Center(
child: Text('Version mobile à implémenter'), // child: Text('Version mobile à implémenter'),
); // );
}, },
), ),
); );
+1 -2
View File
@@ -1,8 +1,7 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
class TokenService { class TokenService {
static const _storage = FlutterSecureStorage(); // static const _storage = FlutterSecureStorage();
static const _tokenKey = 'access_token'; static const _tokenKey = 'access_token';
static const String _refreshTokenKey = 'refresh_token'; static const String _refreshTokenKey = 'refresh_token';
static const _roleKey = 'user_role'; static const _roleKey = 'user_role';
+105
View File
@@ -0,0 +1,105 @@
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:p_tits_pas/services/api/api_config.dart';
import 'package:p_tits_pas/services/api/tokenService.dart';
import 'package:http/http.dart' as http;
class UserService {
final String baseUrl = ApiConfig.baseUrl;
//Recuperer tous les utilisateurs
Future<List<Map<String, dynamic>>> getAllUsers() async {
try {
final token = await TokenService.getToken();
if (token == null) {
throw Exception('Token non disponible');
}
final response = await http.get(
Uri.parse('$baseUrl${ApiConfig.users}'),
headers: ApiConfig.authHeaders(token),
);
if (response.statusCode == 200) {
final List<dynamic> data = jsonDecode(response.body);
return data.cast<Map<String, dynamic>>();
} else {
throw Exception('Erreur lors de la récupération des utilisateurs: ${response.statusCode}');
}
} catch (e) {
throw Exception('Erreur de connexion: $e');
}
}
//Récuperer les utilisateurs en fonction du role
Future<List<Map<String, dynamic>>> getUsersByRole(String role) async {
try {
final allUsers = await getAllUsers();
return allUsers.where((user) =>
user['role']?.toString().toLowerCase() == role.toLowerCase()
).toList();
} catch (e) {
throw Exception('Erreur lors de la récupération des utilisateurs par rôle: $e');
}
}
// Filtrer les utilisateurs par statut
Future<List<Map<String, dynamic>>> filterUsersByStatus(String? status) async {
try {
final allUsers = await getAllUsers();
if (status == null || status.isEmpty) return allUsers;
return allUsers
.where((user) =>
user['status']?.toString().toLowerCase() == status.toLowerCase())
.toList();
} catch (e) {
throw Exception('Erreur lors du filtrage: $e');
}
}
/// Supprimer un utilisateur
Future<bool> deleteUser(String userId) async {
try {
final token = await TokenService.getToken();
if (token == null) {
throw Exception('Token non disponible');
}
final response = await http.delete(
Uri.parse('$baseUrl${ApiConfig.users}/$userId'),
headers: ApiConfig.authHeaders(token),
);
return response.statusCode == 200 || response.statusCode == 204;
} catch (e) {
throw Exception('Erreur lors de la suppression: $e');
}
}
/// Récupérer les détails d'un utilisateur
Future<Map<String, dynamic>?> getUserById(String userId) async {
try {
final token = await TokenService.getToken();
if (token == null) {
throw Exception('Token non disponible');
}
final response = await http.get(
Uri.parse('$baseUrl${ApiConfig.users}/$userId'),
headers: ApiConfig.authHeaders(token),
);
if (response.statusCode == 200) {
return jsonDecode(response.body);
} else {
return null;
}
} catch (e) {
throw Exception('Erreur lors de la récupération de l\'utilisateur: $e');
}
}
}
@@ -1,84 +1,218 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:p_tits_pas/services/user_service.dart';
class ParentManagementWidget extends StatelessWidget { class ParentManagementWidget extends StatefulWidget {
const ParentManagementWidget({super.key}); const ParentManagementWidget({super.key});
@override @override
Widget build(BuildContext context) { State<ParentManagementWidget> createState() => _ParentManagementWidgetState();
// 🔁 Simulation de données parents }
final parents = [
{
"nom": "Jean Dupuis",
"email": "jean.dupuis@email.com",
"statut": "Actif",
"enfants": 2,
},
{
"nom": "Lucie Morel",
"email": "lucie.morel@email.com",
"statut": "En attente",
"enfants": 1,
},
];
class _ParentManagementWidgetState extends State<ParentManagementWidget> {
final UserService _userService = UserService();
final TextEditingController _searchController = TextEditingController();
List<Map<String, dynamic>> _allParents = [];
List<Map<String, dynamic>> _filteredParents = [];
String? _selectedStatus;
bool _isLoading = true;
String? _error;
@override
void initState() {
super.initState();
_loadParents();
}
@override
void dispose() {
_searchController.dispose();
super.dispose();
}
Future <void> _loadParents() async {
setState(() {
_isLoading = true;
_error = null;
});
try {
final parents = await _userService.getUsersByRole("parent");
setState(() {
_allParents = parents;
_filteredParents = parents;
_isLoading = false;
});
} catch (e) {
setState(() {
_error = e.toString();
_isLoading = false;
});
}
}
void _applyFilters() {
setState(() {
_filteredParents = _allParents.where((parent) {
final searchQuery = _searchController.text.toLowerCase();
final fullName = '${parent['prenom'] ?? ''} ${parent['nom'] ?? ''}'.toLowerCase();
final email = (parent['email'] ?? '').toLowerCase();
bool matchesSearch = searchQuery.isEmpty ||
fullName.contains(searchQuery) ||
email.contains(searchQuery);
bool matchesStatus = _selectedStatus == null ||
_selectedStatus!.isEmpty ||
parent['statut']?.toString() == _selectedStatus;
return matchesSearch && matchesStatus;
}).toList();
});
}
String _getStatusDisplay(Map<String, dynamic> parent) {
final status = parent['statut'];
if (status == null) return 'Non défini';
switch (status.toString().toLowerCase()) {
case 'actif':
return 'Actif';
case 'en_attente':
return 'En attente';
case 'inactif':
return 'Inactif';
case 'supprimé':
return 'Supprimé';
default:
return status.toString();
}
}
Color _getStatusColor(Map<String, dynamic> parent) {
final status = parent['statut']?.toString().toLowerCase();
switch (status) {
case 'actif':
return Colors.green;
case 'en_attente':
return Colors.orange;
case 'inactif':
return Colors.grey;
case 'supprimé':
return Colors.red;
default:
return Colors.grey;
}
}
Future<void> _confirmDelete(Map<String, dynamic> parent) async {
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: const Text('Confirmer la suppression'),
content: Text(
'Êtes-vous sûr de vouloir supprimer le compte de ${parent['firstName']} ${parent['lastName']} ?'
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(false),
child: const Text('Annuler'),
),
TextButton(
onPressed: () => Navigator.of(context).pop(true),
style: TextButton.styleFrom(foregroundColor: Colors.red),
child: const Text('Supprimer'),
),
],
),
);
if (confirmed == true) {
await _deleteParent(parent);
}
}
Future<void> _deleteParent(Map<String, dynamic> parent) async {
try {
final success = await _userService.deleteUser(parent['id']);
if (success) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('${parent['firstName']} ${parent['lastName']} supprimé avec succès'),
backgroundColor: Colors.green,
),
);
_loadParents(); // Recharger la liste
} else {
throw Exception('Erreur lors de la suppression');
}
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Erreur: ${e.toString()}'),
backgroundColor: Colors.red,
),
);
}
}
void _viewParentDetails(Map<String, dynamic> parent) {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text('${parent['firstName']} ${parent['lastName']}'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Email: ${parent['email']}'),
Text('Rôle: ${parent['role']}'),
Text('Statut: ${_getStatusDisplay(parent)}'),
Text('ID: ${parent['id']}'),
if (parent['createdAt'] != null)
Text('Créé le: ${DateTime.parse(parent['createdAt']).toLocal().toString().split(' ')[0]}'),
],
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const Text('Fermer'),
),
],
),
);
}
Widget build(BuildContext context) {
return Padding( return Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row(
_buildSearchSection(), mainAxisAlignment: MainAxisAlignment.spaceBetween,
const SizedBox(height: 16),
ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: parents.length,
itemBuilder: (context, index) {
final parent = parents[index];
return Card(
margin: const EdgeInsets.symmetric(vertical: 8),
child: ListTile(
leading: const Icon(Icons.person_outline),
title: Text(parent['nom'].toString()),
subtitle: Text(
"${parent['email']}\nStatut : ${parent['statut']} | Enfants : ${parent['enfants']}",
),
isThreeLine: true,
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [ children: [
IconButton( Text(
icon: const Icon(Icons.visibility), 'Gestion des Parents (${_filteredParents.length})',
tooltip: "Voir dossier", style: Theme.of(context).textTheme.headlineSmall,
onPressed: () {
// TODO: Voir le statut du dossier
},
), ),
IconButton( IconButton(
icon: const Icon(Icons.edit), icon: const Icon(Icons.refresh),
tooltip: "Modifier", onPressed: _loadParents,
onPressed: () { tooltip: 'Actualiser',
// TODO: Modifier parent
},
),
IconButton(
icon: const Icon(Icons.delete),
tooltip: "Supprimer",
onPressed: () {
// TODO: Supprimer compte
},
), ),
], ],
), ),
), const SizedBox(height: 16),
); _buildSearchSection(),
}, const SizedBox(height: 16),
Expanded(
child: _buildParentsList(),
), ),
], ],
) ));
);
} }
Widget _buildSearchSection() { Widget _buildSearchSection() {
@@ -87,35 +221,184 @@ class ParentManagementWidget extends StatelessWidget {
runSpacing: 8, runSpacing: 8,
children: [ children: [
SizedBox( SizedBox(
width: 220, width: 250,
child: TextField( child: TextField(
controller: _searchController,
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "Nom du parent", labelText: "Rechercher un parent",
hintText: "Nom ou email",
border: OutlineInputBorder(), border: OutlineInputBorder(),
prefixIcon: Icon(Icons.search),
), ),
onChanged: (value) { onChanged: (value) => _applyFilters(),
// TODO: Ajouter logique de recherche
},
), ),
), ),
SizedBox( SizedBox(
width: 220, width: 200,
child: DropdownButtonFormField<String>( child: DropdownButtonFormField<String>(
value: _selectedStatus,
decoration: const InputDecoration( decoration: const InputDecoration(
labelText: "Statut", labelText: "Statut",
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
items: const [ items: const [
DropdownMenuItem(value: "Actif", child: Text("Actif")), DropdownMenuItem(value: null, child: Text("Tous")),
DropdownMenuItem(value: "En attente", child: Text("En attente")), DropdownMenuItem(value: "active", child: Text("Actif")),
DropdownMenuItem(value: "Supprimé", child: Text("Supprimé")), DropdownMenuItem(value: "pending", child: Text("En attente")),
DropdownMenuItem(value: "inactive", child: Text("Inactif")),
DropdownMenuItem(value: "deleted", child: Text("Supprimé")),
], ],
onChanged: (value) { onChanged: (value) {
// TODO: Ajouter logique de filtrage setState(() {
_selectedStatus = value;
});
_applyFilters();
}, },
), ),
), ),
], ],
); );
} }
Widget _buildParentsList() {
if (_isLoading) {
return const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
CircularProgressIndicator(),
SizedBox(height: 16),
Text('Chargement des parents...'),
],
),
);
}
if (_error != null) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.error_outline, size: 48, color: Colors.red[300]),
const SizedBox(height: 16),
Text(
'Erreur de chargement',
style: Theme.of(context).textTheme.titleLarge,
),
const SizedBox(height: 8),
Text(
_error!,
textAlign: TextAlign.center,
style: Theme.of(context).textTheme.bodyMedium,
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: _loadParents,
child: const Text('Réessayer'),
),
],
),
);
}
if (_filteredParents.isEmpty) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.people_outline, size: 48, color: Colors.grey[400]),
const SizedBox(height: 16),
Text(
_allParents.isEmpty ? 'Aucun parent trouvé' : 'Aucun résultat',
style: Theme.of(context).textTheme.titleLarge,
),
if (_allParents.isNotEmpty) ...[
const SizedBox(height: 8),
const Text('Essayez de modifier vos critères de recherche'),
],
],
),
);
}
return ListView.builder(
itemCount: _filteredParents.length,
itemBuilder: (context, index) {
final parent = _filteredParents[index];
return Card(
margin: const EdgeInsets.symmetric(vertical: 4),
child: ListTile(
leading: CircleAvatar(
backgroundColor: _getStatusColor(parent).withOpacity(0.2),
child: Text(
'${parent['firstName']?[0] ?? ''}${parent['lastName']?[0] ?? ''}',
style: TextStyle(
color: _getStatusColor(parent),
fontWeight: FontWeight.bold,
),
),
),
title: Text('${parent['firstName'] ?? ''} ${parent['lastName'] ?? ''}'),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(parent['email'] ?? ''),
const SizedBox(height: 4),
Row(
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
decoration: BoxDecoration(
color: _getStatusColor(parent).withOpacity(0.2),
borderRadius: BorderRadius.circular(12),
border: Border.all(color: _getStatusColor(parent)),
),
child: Text(
_getStatusDisplay(parent),
style: TextStyle(
color: _getStatusColor(parent),
fontSize: 12,
fontWeight: FontWeight.w500,
),
),
),
],
),
],
),
isThreeLine: true,
trailing: Row(
mainAxisSize: MainAxisSize.min,
children: [
IconButton(
icon: const Icon(Icons.visibility, color: Colors.blue),
tooltip: "Voir détails",
onPressed: () => _viewParentDetails(parent),
),
IconButton(
icon: const Icon(Icons.edit, color: Colors.orange),
tooltip: "Modifier",
onPressed: () {
// TODO: Implémenter la modification
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Fonctionnalité de modification à implémenter'),
),
);
},
),
IconButton(
icon: const Icon(Icons.delete, color: Colors.red),
tooltip: "Supprimer",
onPressed: () => _confirmDelete(parent),
),
],
),
),
);
},
);
}
} }
-56
View File
@@ -139,54 +139,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.28" version: "2.0.28"
flutter_secure_storage:
dependency: "direct main"
description:
name: flutter_secure_storage
sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea"
url: "https://pub.dev"
source: hosted
version: "9.2.4"
flutter_secure_storage_linux:
dependency: transitive
description:
name: flutter_secure_storage_linux
sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688
url: "https://pub.dev"
source: hosted
version: "1.2.3"
flutter_secure_storage_macos:
dependency: transitive
description:
name: flutter_secure_storage_macos
sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247"
url: "https://pub.dev"
source: hosted
version: "3.1.3"
flutter_secure_storage_platform_interface:
dependency: transitive
description:
name: flutter_secure_storage_platform_interface
sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8
url: "https://pub.dev"
source: hosted
version: "1.1.2"
flutter_secure_storage_web:
dependency: transitive
description:
name: flutter_secure_storage_web
sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9
url: "https://pub.dev"
source: hosted
version: "1.2.1"
flutter_secure_storage_windows:
dependency: transitive
description:
name: flutter_secure_storage_windows
sha256: b20b07cb5ed4ed74fc567b78a72936203f587eba460af1df11281c9326cd3709
url: "https://pub.dev"
source: hosted
version: "3.1.2"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@@ -674,14 +626,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.1" version: "1.1.1"
win32:
dependency: transitive
description:
name: win32
sha256: "329edf97fdd893e0f1e3b9e88d6a0e627128cc17cc316a8d67fda8f1451178ba"
url: "https://pub.dev"
source: hosted
version: "5.13.0"
xdg_directories: xdg_directories:
dependency: transitive dependency: transitive
description: description:
+2 -2
View File
@@ -18,8 +18,8 @@ dependencies:
image_picker: ^1.0.7 image_picker: ^1.0.7
js: ^0.6.7 js: ^0.6.7
url_launcher: ^6.2.4 url_launcher: ^6.2.4
http: ^1.5.0 http: ^1.2.2
flutter_secure_storage: ^9.2.4 # flutter_secure_storage: ^9.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@@ -7,14 +7,11 @@
#include "generated_plugin_registrant.h" #include "generated_plugin_registrant.h"
#include <file_selector_windows/file_selector_windows.h> #include <file_selector_windows/file_selector_windows.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) { void RegisterPlugins(flutter::PluginRegistry* registry) {
FileSelectorWindowsRegisterWithRegistrar( FileSelectorWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FileSelectorWindows")); registry->GetRegistrarForPlugin("FileSelectorWindows"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
UrlLauncherWindowsRegisterWithRegistrar( UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows")); registry->GetRegistrarForPlugin("UrlLauncherWindows"));
} }
@@ -4,7 +4,6 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
file_selector_windows file_selector_windows
flutter_secure_storage_windows
url_launcher_windows url_launcher_windows
) )