feat(#44): dashboard gestionnaire + redirection login rôle gestionnaire
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
e8c6665a06
commit
e990d576cf
@ -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(),
|
||||
|
||||
@ -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,45 @@
|
||||
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 [AdminUserManagementPanel].
|
||||
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: [
|
||||
const Expanded(child: AdminUserManagementPanel()),
|
||||
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,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user