feat(admin): première connexion → panneau Paramètres, reste grisé jusqu'à Sauvegarder (#14)
- 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>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
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';
|
||||
@@ -14,12 +15,34 @@ class AdminDashboardScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -34,6 +57,11 @@ class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
||||
|
||||
@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),
|
||||
@@ -46,6 +74,7 @@ class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
||||
child: DashboardAppBarAdmin(
|
||||
selectedIndex: mainTabIndex,
|
||||
onTabChange: onMainTabChange,
|
||||
setupCompleted: _setupCompleted!,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -67,7 +96,9 @@ class _AdminDashboardScreenState extends State<AdminDashboardScreen> {
|
||||
|
||||
Widget _getBody() {
|
||||
if (mainTabIndex == 1) {
|
||||
return const ParametresPanel();
|
||||
return ParametresPanel(
|
||||
onSetupCompleted: () => setState(() => _setupCompleted = true),
|
||||
);
|
||||
}
|
||||
switch (subIndex) {
|
||||
case 0:
|
||||
|
||||
Reference in New Issue
Block a user