merge: squash develop into master (#44 Dashboard Gestionnaire - Structure)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
619e39219f
commit
fffe8cd202
@ -20,6 +20,7 @@ import '../screens/auth/am_register_step3_screen.dart';
|
||||
import '../screens/auth/am_register_step4_screen.dart';
|
||||
import '../screens/home/home_screen.dart';
|
||||
import '../screens/administrateurs/admin_dashboardScreen.dart';
|
||||
import '../screens/gestionnaire/gestionnaire_dashboard_screen.dart';
|
||||
import '../screens/home/parent_screen/ParentDashboardScreen.dart';
|
||||
import '../screens/unknown_screen.dart';
|
||||
|
||||
@ -53,6 +54,10 @@ class AppRouter {
|
||||
path: '/admin-dashboard',
|
||||
builder: (BuildContext context, GoRouterState state) => const AdminDashboardScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/gestionnaire-dashboard',
|
||||
builder: (BuildContext context, GoRouterState state) => const GestionnaireDashboardScreen(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/parent-dashboard',
|
||||
builder: (BuildContext context, GoRouterState state) => const ParentDashboardScreen(),
|
||||
|
||||
@ -106,6 +106,6 @@ class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
||||
selectedSettingsTabIndex: settingsSubIndex,
|
||||
);
|
||||
}
|
||||
return const AdminUserManagementPanel();
|
||||
return const UserManagementPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,9 +131,11 @@ class _LoginPageState extends State<LoginScreen> with WidgetsBindingObserver {
|
||||
switch (role.toLowerCase()) {
|
||||
case 'super_admin':
|
||||
case 'administrateur':
|
||||
case 'gestionnaire':
|
||||
context.go('/admin-dashboard');
|
||||
break;
|
||||
case 'gestionnaire':
|
||||
context.go('/gestionnaire-dashboard');
|
||||
break;
|
||||
case 'parent':
|
||||
context.go('/parent-dashboard');
|
||||
break;
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/dashboard_admin.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/user_management_panel.dart';
|
||||
import 'package:p_tits_pas/widgets/app_footer.dart';
|
||||
|
||||
/// Dashboard gestionnaire – même shell que l'admin, sans onglet Paramètres.
|
||||
/// Réutilise [UserManagementPanel].
|
||||
class GestionnaireDashboardScreen extends StatefulWidget {
|
||||
const GestionnaireDashboardScreen({super.key});
|
||||
|
||||
@override
|
||||
State<GestionnaireDashboardScreen> createState() =>
|
||||
_GestionnaireDashboardScreenState();
|
||||
}
|
||||
|
||||
class _GestionnaireDashboardScreenState extends State<GestionnaireDashboardScreen> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: const Size.fromHeight(60.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(color: Colors.grey.shade300),
|
||||
),
|
||||
),
|
||||
child: DashboardAppBarAdmin(
|
||||
selectedIndex: 0,
|
||||
onTabChange: (_) {},
|
||||
showSettingsTab: false,
|
||||
roleLabel: 'Gestionnaire',
|
||||
setupCompleted: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: UserManagementPanel(showAdministrateursTab: false),
|
||||
),
|
||||
const AppFooter(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -3,17 +3,22 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:p_tits_pas/services/auth_service.dart';
|
||||
|
||||
/// Barre du dashboard admin : onglets Gestion des utilisateurs | Paramètres + déconnexion.
|
||||
/// Pour le dashboard gestionnaire : [showSettingsTab] = false, [roleLabel] = 'Gestionnaire'.
|
||||
class DashboardAppBarAdmin extends StatelessWidget
|
||||
implements PreferredSizeWidget {
|
||||
final int selectedIndex;
|
||||
final ValueChanged<int> onTabChange;
|
||||
final bool setupCompleted;
|
||||
final bool showSettingsTab;
|
||||
final String roleLabel;
|
||||
|
||||
const DashboardAppBarAdmin({
|
||||
Key? key,
|
||||
required this.selectedIndex,
|
||||
required this.onTabChange,
|
||||
this.setupCompleted = true,
|
||||
this.showSettingsTab = true,
|
||||
this.roleLabel = 'Admin',
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -39,8 +44,10 @@ class DashboardAppBarAdmin extends StatelessWidget
|
||||
children: [
|
||||
_buildNavItem(context, 'Gestion des utilisateurs', 0,
|
||||
enabled: setupCompleted),
|
||||
const SizedBox(width: 24),
|
||||
_buildNavItem(context, 'Paramètres', 1, enabled: true),
|
||||
if (showSettingsTab) ...[
|
||||
const SizedBox(width: 24),
|
||||
_buildNavItem(context, 'Paramètres', 1, enabled: true),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -48,12 +55,12 @@ class DashboardAppBarAdmin extends StatelessWidget
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Admin',
|
||||
style: TextStyle(
|
||||
roleLabel,
|
||||
style: const TextStyle(
|
||||
color: Colors.black,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
@ -132,7 +139,8 @@ class DashboardAppBarAdmin extends StatelessWidget
|
||||
}
|
||||
}
|
||||
|
||||
/// Sous-barre : Gestionnaires | Parents | Assistantes maternelles | Administrateurs.
|
||||
/// Sous-barre : Gestionnaires | Parents | Assistantes maternelles | [Administrateurs].
|
||||
/// [subTabCount] = 3 pour masquer l'onglet Administrateurs (dashboard gestionnaire).
|
||||
class DashboardUserManagementSubBar extends StatelessWidget {
|
||||
final int selectedSubIndex;
|
||||
final ValueChanged<int> onSubTabChange;
|
||||
@ -141,6 +149,14 @@ class DashboardUserManagementSubBar extends StatelessWidget {
|
||||
final Widget? filterControl;
|
||||
final VoidCallback? onAddPressed;
|
||||
final String addLabel;
|
||||
final int subTabCount;
|
||||
|
||||
static const List<String> _tabLabels = [
|
||||
'Gestionnaires',
|
||||
'Parents',
|
||||
'Assistantes maternelles',
|
||||
'Administrateurs',
|
||||
];
|
||||
|
||||
const DashboardUserManagementSubBar({
|
||||
Key? key,
|
||||
@ -151,6 +167,7 @@ class DashboardUserManagementSubBar extends StatelessWidget {
|
||||
this.filterControl,
|
||||
this.onAddPressed,
|
||||
this.addLabel = '+ Ajouter',
|
||||
this.subTabCount = 4,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -164,13 +181,10 @@ class DashboardUserManagementSubBar extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 6),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildSubNavItem(context, 'Gestionnaires', 0),
|
||||
const SizedBox(width: 12),
|
||||
_buildSubNavItem(context, 'Parents', 1),
|
||||
const SizedBox(width: 12),
|
||||
_buildSubNavItem(context, 'Assistantes maternelles', 2),
|
||||
const SizedBox(width: 12),
|
||||
_buildSubNavItem(context, 'Administrateurs', 3),
|
||||
for (int i = 0; i < subTabCount; i++) ...[
|
||||
if (i > 0) const SizedBox(width: 12),
|
||||
_buildSubNavItem(context, _tabLabels[i], i),
|
||||
],
|
||||
const SizedBox(width: 36),
|
||||
_pillField(
|
||||
width: 320,
|
||||
|
||||
@ -6,15 +6,20 @@ import 'package:p_tits_pas/widgets/admin/dashboard_admin.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/gestionnaire_management_widget.dart';
|
||||
import 'package:p_tits_pas/widgets/admin/parent_managmant_widget.dart';
|
||||
|
||||
class AdminUserManagementPanel extends StatefulWidget {
|
||||
const AdminUserManagementPanel({super.key});
|
||||
class UserManagementPanel extends StatefulWidget {
|
||||
/// Afficher l'onglet Administrateurs (sinon 3 onglets : Gestionnaires, Parents, AM).
|
||||
final bool showAdministrateursTab;
|
||||
|
||||
const UserManagementPanel({
|
||||
super.key,
|
||||
this.showAdministrateursTab = true,
|
||||
});
|
||||
|
||||
@override
|
||||
State<AdminUserManagementPanel> createState() =>
|
||||
_AdminUserManagementPanelState();
|
||||
State<UserManagementPanel> createState() => _UserManagementPanelState();
|
||||
}
|
||||
|
||||
class _AdminUserManagementPanelState extends State<AdminUserManagementPanel> {
|
||||
class _UserManagementPanelState extends State<UserManagementPanel> {
|
||||
int _subIndex = 0;
|
||||
int _gestionnaireRefreshTick = 0;
|
||||
int _adminRefreshTick = 0;
|
||||
@ -44,8 +49,9 @@ class _AdminUserManagementPanelState extends State<AdminUserManagementPanel> {
|
||||
}
|
||||
|
||||
void _onSubTabChange(int index) {
|
||||
final maxIndex = widget.showAdministrateursTab ? 3 : 2;
|
||||
setState(() {
|
||||
_subIndex = index;
|
||||
_subIndex = index.clamp(0, maxIndex);
|
||||
_searchController.clear();
|
||||
_parentStatus = null;
|
||||
_amCapacityController.clear();
|
||||
@ -161,6 +167,7 @@ class _AdminUserManagementPanelState extends State<AdminUserManagementPanel> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final subTabCount = widget.showAdministrateursTab ? 4 : 3;
|
||||
return Column(
|
||||
children: [
|
||||
DashboardUserManagementSubBar(
|
||||
@ -171,6 +178,7 @@ class _AdminUserManagementPanelState extends State<AdminUserManagementPanel> {
|
||||
filterControl: _subBarFilterControl(),
|
||||
onAddPressed: _handleAddPressed,
|
||||
addLabel: 'Ajouter',
|
||||
subTabCount: subTabCount,
|
||||
),
|
||||
Expanded(child: _buildBody()),
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user