- Au chargement admin: appel getSetupStatus(), si non terminé → onglet Paramètres par défaut - Onglet Gestion des utilisateurs grisé et inaccessible tant que setup non complété - Sauvegarder: updateBulk + completeSetup + déblocage des panneaux - Tester SMTP: saveBulkOnly puis test (sans completeSetup, panneaux restent verrouillés) Co-authored-by: Cursor <cursoragent@cursor.com>
117 lines
3.2 KiB
Dart
117 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:p_tits_pas/services/configuration_service.dart';
|
|
import 'package:p_tits_pas/widgets/admin/assistante_maternelle_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/parametres_panel.dart';
|
|
import 'package:p_tits_pas/widgets/app_footer.dart';
|
|
import 'package:p_tits_pas/widgets/admin/dashboard_admin.dart';
|
|
|
|
class AdminDashboardScreen extends StatefulWidget {
|
|
const AdminDashboardScreen({super.key});
|
|
|
|
@override
|
|
State<AdminDashboardScreen> createState() => _AdminDashboardScreenState();
|
|
}
|
|
|
|
class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
|
/// null = chargement du statut setup, true/false = connu
|
|
bool? _setupCompleted;
|
|
|
|
/// 0 = Gestion des utilisateurs, 1 = Paramètres
|
|
int mainTabIndex = 0;
|
|
|
|
/// Sous-onglet quand mainTabIndex == 0 : 0=Gestionnaires, 1=Parents, 2=AM, 3=Administrateurs
|
|
int subIndex = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_loadSetupStatus();
|
|
}
|
|
|
|
Future<void> _loadSetupStatus() async {
|
|
try {
|
|
final completed = await ConfigurationService.getSetupStatus();
|
|
if (!mounted) return;
|
|
setState(() {
|
|
_setupCompleted = completed;
|
|
if (!completed) mainTabIndex = 1;
|
|
});
|
|
} catch (_) {
|
|
if (mounted) setState(() => _setupCompleted = true);
|
|
}
|
|
}
|
|
|
|
void onMainTabChange(int index) {
|
|
setState(() {
|
|
mainTabIndex = index;
|
|
});
|
|
}
|
|
|
|
void onSubTabChange(int index) {
|
|
setState(() {
|
|
subIndex = index;
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (_setupCompleted == null) {
|
|
return const Scaffold(
|
|
body: Center(child: CircularProgressIndicator()),
|
|
);
|
|
}
|
|
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: mainTabIndex,
|
|
onTabChange: onMainTabChange,
|
|
setupCompleted: _setupCompleted!,
|
|
),
|
|
),
|
|
),
|
|
body: Column(
|
|
children: [
|
|
if (mainTabIndex == 0)
|
|
DashboardUserManagementSubBar(
|
|
selectedSubIndex: subIndex,
|
|
onSubTabChange: onSubTabChange,
|
|
),
|
|
Expanded(
|
|
child: _getBody(),
|
|
),
|
|
const AppFooter(),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _getBody() {
|
|
if (mainTabIndex == 1) {
|
|
return ParametresPanel(
|
|
onSetupCompleted: () => setState(() => _setupCompleted = true),
|
|
);
|
|
}
|
|
switch (subIndex) {
|
|
case 0:
|
|
return const GestionnaireManagementWidget();
|
|
case 1:
|
|
return const ParentManagementWidget();
|
|
case 2:
|
|
return const AssistanteMaternelleManagementWidget();
|
|
case 3:
|
|
return const Center(child: Text('👨💼 Administrateurs'));
|
|
default:
|
|
return const Center(child: Text('Page non trouvée'));
|
|
}
|
|
}
|
|
}
|