Refactoring - Version stable
This commit is contained in:
@@ -94,7 +94,13 @@ class DashboardBloc extends Bloc<DashboardEvent, DashboardState> {
|
||||
);
|
||||
|
||||
result.fold(
|
||||
(failure) => emit(DashboardError(_mapFailureToMessage(failure))),
|
||||
(failure) {
|
||||
if (failure is NotFoundFailure) {
|
||||
emit(const DashboardMemberNotRegistered());
|
||||
} else {
|
||||
emit(DashboardError(_mapFailureToMessage(failure)));
|
||||
}
|
||||
},
|
||||
(dashboardData) => emit(DashboardLoaded(dashboardData)),
|
||||
);
|
||||
}
|
||||
@@ -271,14 +277,16 @@ class DashboardBloc extends Bloc<DashboardEvent, DashboardState> {
|
||||
}
|
||||
|
||||
String _mapFailureToMessage(Failure failure) {
|
||||
switch (failure.runtimeType) {
|
||||
case ServerFailure:
|
||||
return 'Erreur serveur. Veuillez réessayer.';
|
||||
case NetworkFailure:
|
||||
return 'Pas de connexion internet. Vérifiez votre connexion.';
|
||||
default:
|
||||
return 'Une erreur inattendue s\'est produite.';
|
||||
if (failure is NetworkFailure) {
|
||||
return 'Pas de connexion internet. Vérifiez votre connexion.';
|
||||
}
|
||||
if (failure is UnauthorizedFailure) {
|
||||
return 'Session expirée. Veuillez vous reconnecter.';
|
||||
}
|
||||
if (failure is NotFoundFailure) {
|
||||
return failure.userFriendlyMessage ?? 'Ressource non trouvée.';
|
||||
}
|
||||
return 'Erreur serveur. Veuillez réessayer.';
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -37,3 +37,9 @@ class DashboardError extends DashboardState {
|
||||
@override
|
||||
List<Object> get props => [message];
|
||||
}
|
||||
|
||||
/// État émis quand l'utilisateur est authentifié dans Keycloak
|
||||
/// mais n'a pas encore de fiche membre en base de données.
|
||||
class DashboardMemberNotRegistered extends DashboardState {
|
||||
const DashboardMemberNotRegistered();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,10 @@ class _ConnectedDashboardPageState extends State<ConnectedDashboardPage> with Si
|
||||
);
|
||||
}
|
||||
|
||||
if (state is DashboardMemberNotRegistered) {
|
||||
return _buildMemberNotRegisteredState();
|
||||
}
|
||||
|
||||
if (state is DashboardError) {
|
||||
return _buildErrorState(state.message);
|
||||
}
|
||||
@@ -624,6 +628,78 @@ class _ConnectedDashboardPageState extends State<ConnectedDashboardPage> with Si
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildMemberNotRegisteredState() {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(28),
|
||||
decoration: BoxDecoration(
|
||||
gradient: UnionFlowColors.primaryGradient,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: const Icon(
|
||||
Icons.person_add_alt_1_outlined,
|
||||
size: 56,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 28),
|
||||
const Text(
|
||||
'Bienvenue dans UnionFlow',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w800,
|
||||
color: UnionFlowColors.textPrimary,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
const Text(
|
||||
'Votre compte est en cours de configuration par un administrateur. '
|
||||
'Votre tableau de bord sera disponible dès que votre profil membre aura été activé.',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: UnionFlowColors.textSecondary,
|
||||
height: 1.5,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: UnionFlowColors.unionGreen.withOpacity(0.08),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: UnionFlowColors.unionGreen.withOpacity(0.3)),
|
||||
),
|
||||
child: const Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(Icons.info_outline, size: 18, color: UnionFlowColors.unionGreen),
|
||||
SizedBox(width: 10),
|
||||
Flexible(
|
||||
child: Text(
|
||||
'Contactez votre administrateur si ce message persiste.',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: UnionFlowColors.unionGreen,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildErrorState(String message) {
|
||||
return Center(
|
||||
child: AnimatedFadeIn(
|
||||
|
||||
Reference in New Issue
Block a user