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/auth/am_register_step4_screen.dart';
|
||||||
import '../screens/home/home_screen.dart';
|
import '../screens/home/home_screen.dart';
|
||||||
import '../screens/administrateurs/admin_dashboardScreen.dart';
|
import '../screens/administrateurs/admin_dashboardScreen.dart';
|
||||||
|
import '../screens/gestionnaire/gestionnaire_dashboard_screen.dart';
|
||||||
import '../screens/home/parent_screen/ParentDashboardScreen.dart';
|
import '../screens/home/parent_screen/ParentDashboardScreen.dart';
|
||||||
import '../screens/unknown_screen.dart';
|
import '../screens/unknown_screen.dart';
|
||||||
|
|
||||||
@ -53,6 +54,10 @@ class AppRouter {
|
|||||||
path: '/admin-dashboard',
|
path: '/admin-dashboard',
|
||||||
builder: (BuildContext context, GoRouterState state) => const AdminDashboardScreen(),
|
builder: (BuildContext context, GoRouterState state) => const AdminDashboardScreen(),
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: '/gestionnaire-dashboard',
|
||||||
|
builder: (BuildContext context, GoRouterState state) => const GestionnaireDashboardScreen(),
|
||||||
|
),
|
||||||
GoRoute(
|
GoRoute(
|
||||||
path: '/parent-dashboard',
|
path: '/parent-dashboard',
|
||||||
builder: (BuildContext context, GoRouterState state) => const ParentDashboardScreen(),
|
builder: (BuildContext context, GoRouterState state) => const ParentDashboardScreen(),
|
||||||
|
|||||||
@ -106,6 +106,6 @@ class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
|||||||
selectedSettingsTabIndex: settingsSubIndex,
|
selectedSettingsTabIndex: settingsSubIndex,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return const AdminUserManagementPanel();
|
return const UserManagementPanel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -131,9 +131,11 @@ class _LoginPageState extends State<LoginScreen> with WidgetsBindingObserver {
|
|||||||
switch (role.toLowerCase()) {
|
switch (role.toLowerCase()) {
|
||||||
case 'super_admin':
|
case 'super_admin':
|
||||||
case 'administrateur':
|
case 'administrateur':
|
||||||
case 'gestionnaire':
|
|
||||||
context.go('/admin-dashboard');
|
context.go('/admin-dashboard');
|
||||||
break;
|
break;
|
||||||
|
case 'gestionnaire':
|
||||||
|
context.go('/gestionnaire-dashboard');
|
||||||
|
break;
|
||||||
case 'parent':
|
case 'parent':
|
||||||
context.go('/parent-dashboard');
|
context.go('/parent-dashboard');
|
||||||
break;
|
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';
|
import 'package:p_tits_pas/services/auth_service.dart';
|
||||||
|
|
||||||
/// Barre du dashboard admin : onglets Gestion des utilisateurs | Paramètres + déconnexion.
|
/// Barre du dashboard admin : onglets Gestion des utilisateurs | Paramètres + déconnexion.
|
||||||
|
/// Pour le dashboard gestionnaire : [showSettingsTab] = false, [roleLabel] = 'Gestionnaire'.
|
||||||
class DashboardAppBarAdmin extends StatelessWidget
|
class DashboardAppBarAdmin extends StatelessWidget
|
||||||
implements PreferredSizeWidget {
|
implements PreferredSizeWidget {
|
||||||
final int selectedIndex;
|
final int selectedIndex;
|
||||||
final ValueChanged<int> onTabChange;
|
final ValueChanged<int> onTabChange;
|
||||||
final bool setupCompleted;
|
final bool setupCompleted;
|
||||||
|
final bool showSettingsTab;
|
||||||
|
final String roleLabel;
|
||||||
|
|
||||||
const DashboardAppBarAdmin({
|
const DashboardAppBarAdmin({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.selectedIndex,
|
required this.selectedIndex,
|
||||||
required this.onTabChange,
|
required this.onTabChange,
|
||||||
this.setupCompleted = true,
|
this.setupCompleted = true,
|
||||||
|
this.showSettingsTab = true,
|
||||||
|
this.roleLabel = 'Admin',
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -39,8 +44,10 @@ class DashboardAppBarAdmin extends StatelessWidget
|
|||||||
children: [
|
children: [
|
||||||
_buildNavItem(context, 'Gestion des utilisateurs', 0,
|
_buildNavItem(context, 'Gestion des utilisateurs', 0,
|
||||||
enabled: setupCompleted),
|
enabled: setupCompleted),
|
||||||
const SizedBox(width: 24),
|
if (showSettingsTab) ...[
|
||||||
_buildNavItem(context, 'Paramètres', 1, enabled: true),
|
const SizedBox(width: 24),
|
||||||
|
_buildNavItem(context, 'Paramètres', 1, enabled: true),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -48,12 +55,12 @@ class DashboardAppBarAdmin extends StatelessWidget
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
const Padding(
|
Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Admin',
|
roleLabel,
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
fontWeight: FontWeight.w500,
|
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 {
|
class DashboardUserManagementSubBar extends StatelessWidget {
|
||||||
final int selectedSubIndex;
|
final int selectedSubIndex;
|
||||||
final ValueChanged<int> onSubTabChange;
|
final ValueChanged<int> onSubTabChange;
|
||||||
@ -141,6 +149,14 @@ class DashboardUserManagementSubBar extends StatelessWidget {
|
|||||||
final Widget? filterControl;
|
final Widget? filterControl;
|
||||||
final VoidCallback? onAddPressed;
|
final VoidCallback? onAddPressed;
|
||||||
final String addLabel;
|
final String addLabel;
|
||||||
|
final int subTabCount;
|
||||||
|
|
||||||
|
static const List<String> _tabLabels = [
|
||||||
|
'Gestionnaires',
|
||||||
|
'Parents',
|
||||||
|
'Assistantes maternelles',
|
||||||
|
'Administrateurs',
|
||||||
|
];
|
||||||
|
|
||||||
const DashboardUserManagementSubBar({
|
const DashboardUserManagementSubBar({
|
||||||
Key? key,
|
Key? key,
|
||||||
@ -151,6 +167,7 @@ class DashboardUserManagementSubBar extends StatelessWidget {
|
|||||||
this.filterControl,
|
this.filterControl,
|
||||||
this.onAddPressed,
|
this.onAddPressed,
|
||||||
this.addLabel = '+ Ajouter',
|
this.addLabel = '+ Ajouter',
|
||||||
|
this.subTabCount = 4,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -164,13 +181,10 @@ class DashboardUserManagementSubBar extends StatelessWidget {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 6),
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 6),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
_buildSubNavItem(context, 'Gestionnaires', 0),
|
for (int i = 0; i < subTabCount; i++) ...[
|
||||||
const SizedBox(width: 12),
|
if (i > 0) const SizedBox(width: 12),
|
||||||
_buildSubNavItem(context, 'Parents', 1),
|
_buildSubNavItem(context, _tabLabels[i], i),
|
||||||
const SizedBox(width: 12),
|
],
|
||||||
_buildSubNavItem(context, 'Assistantes maternelles', 2),
|
|
||||||
const SizedBox(width: 12),
|
|
||||||
_buildSubNavItem(context, 'Administrateurs', 3),
|
|
||||||
const SizedBox(width: 36),
|
const SizedBox(width: 36),
|
||||||
_pillField(
|
_pillField(
|
||||||
width: 320,
|
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/gestionnaire_management_widget.dart';
|
||||||
import 'package:p_tits_pas/widgets/admin/parent_managmant_widget.dart';
|
import 'package:p_tits_pas/widgets/admin/parent_managmant_widget.dart';
|
||||||
|
|
||||||
class AdminUserManagementPanel extends StatefulWidget {
|
class UserManagementPanel extends StatefulWidget {
|
||||||
const AdminUserManagementPanel({super.key});
|
/// Afficher l'onglet Administrateurs (sinon 3 onglets : Gestionnaires, Parents, AM).
|
||||||
|
final bool showAdministrateursTab;
|
||||||
|
|
||||||
|
const UserManagementPanel({
|
||||||
|
super.key,
|
||||||
|
this.showAdministrateursTab = true,
|
||||||
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AdminUserManagementPanel> createState() =>
|
State<UserManagementPanel> createState() => _UserManagementPanelState();
|
||||||
_AdminUserManagementPanelState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AdminUserManagementPanelState extends State<AdminUserManagementPanel> {
|
class _UserManagementPanelState extends State<UserManagementPanel> {
|
||||||
int _subIndex = 0;
|
int _subIndex = 0;
|
||||||
int _gestionnaireRefreshTick = 0;
|
int _gestionnaireRefreshTick = 0;
|
||||||
int _adminRefreshTick = 0;
|
int _adminRefreshTick = 0;
|
||||||
@ -44,8 +49,9 @@ class _AdminUserManagementPanelState extends State<AdminUserManagementPanel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _onSubTabChange(int index) {
|
void _onSubTabChange(int index) {
|
||||||
|
final maxIndex = widget.showAdministrateursTab ? 3 : 2;
|
||||||
setState(() {
|
setState(() {
|
||||||
_subIndex = index;
|
_subIndex = index.clamp(0, maxIndex);
|
||||||
_searchController.clear();
|
_searchController.clear();
|
||||||
_parentStatus = null;
|
_parentStatus = null;
|
||||||
_amCapacityController.clear();
|
_amCapacityController.clear();
|
||||||
@ -161,6 +167,7 @@ class _AdminUserManagementPanelState extends State<AdminUserManagementPanel> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final subTabCount = widget.showAdministrateursTab ? 4 : 3;
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
DashboardUserManagementSubBar(
|
DashboardUserManagementSubBar(
|
||||||
@ -171,6 +178,7 @@ class _AdminUserManagementPanelState extends State<AdminUserManagementPanel> {
|
|||||||
filterControl: _subBarFilterControl(),
|
filterControl: _subBarFilterControl(),
|
||||||
onAddPressed: _handleAddPressed,
|
onAddPressed: _handleAddPressed,
|
||||||
addLabel: 'Ajouter',
|
addLabel: 'Ajouter',
|
||||||
|
subTabCount: subTabCount,
|
||||||
),
|
),
|
||||||
Expanded(child: _buildBody()),
|
Expanded(child: _buildBody()),
|
||||||
],
|
],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user