refactoring
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
library admin_users_bloc;
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import '../data/models/admin_user_model.dart';
|
||||
@@ -35,6 +36,7 @@ class AdminUsersBloc extends Bloc<AdminUsersEvent, AdminUsersState> {
|
||||
totalPages: result.totalPages,
|
||||
));
|
||||
} catch (err) {
|
||||
if (err is DioException && err.type == DioExceptionType.cancel) return;
|
||||
emit(AdminUsersError(err.toString()));
|
||||
}
|
||||
}
|
||||
@@ -50,6 +52,7 @@ class AdminUsersBloc extends Bloc<AdminUsersEvent, AdminUsersState> {
|
||||
final roles = await _repository.getUserRoles(e.userId);
|
||||
emit(AdminUserDetailLoaded(user: user, userRoles: roles));
|
||||
} catch (err) {
|
||||
if (err is DioException && err.type == DioExceptionType.cancel) return;
|
||||
emit(AdminUsersError(err.toString()));
|
||||
}
|
||||
}
|
||||
@@ -66,6 +69,7 @@ class AdminUsersBloc extends Bloc<AdminUsersEvent, AdminUsersState> {
|
||||
final allRoles = await _repository.getRealmRoles();
|
||||
emit(AdminUserDetailLoaded(user: user, userRoles: userRoles, allRoles: allRoles));
|
||||
} catch (err) {
|
||||
if (err is DioException && err.type == DioExceptionType.cancel) return;
|
||||
emit(AdminUsersError(err.toString()));
|
||||
}
|
||||
}
|
||||
@@ -76,6 +80,7 @@ class AdminUsersBloc extends Bloc<AdminUsersEvent, AdminUsersState> {
|
||||
emit(AdminUserRolesUpdated());
|
||||
add(AdminUserDetailWithRolesRequested(e.userId));
|
||||
} catch (err) {
|
||||
if (err is DioException && err.type == DioExceptionType.cancel) return;
|
||||
emit(AdminUsersError(err.toString()));
|
||||
}
|
||||
}
|
||||
@@ -85,6 +90,7 @@ class AdminUsersBloc extends Bloc<AdminUsersEvent, AdminUsersState> {
|
||||
final roles = await _repository.getRealmRoles();
|
||||
emit(AdminRolesLoaded(roles));
|
||||
} catch (err) {
|
||||
if (err is DioException && err.type == DioExceptionType.cancel) return;
|
||||
emit(AdminUsersError(err.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class _UserDetailContentState extends State<_UserDetailContent> {
|
||||
}
|
||||
},
|
||||
child: SingleChildScrollView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -121,7 +121,7 @@ class _UserDetailContentState extends State<_UserDetailContent> {
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'RÔLES (SÉLECTION)',
|
||||
style: AppTypography.subtitleSmall.copyWith(
|
||||
@@ -149,7 +149,7 @@ class _UserDetailContentState extends State<_UserDetailContent> {
|
||||
},
|
||||
);
|
||||
}),
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 12),
|
||||
UFPrimaryButton(
|
||||
label: 'Enregistrer les rôles',
|
||||
onPressed: () {
|
||||
@@ -158,9 +158,9 @@ class _UserDetailContentState extends State<_UserDetailContent> {
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
const SizedBox(height: 12),
|
||||
const Divider(height: 1),
|
||||
const SizedBox(height: 16),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'ASSOCIER À UNE ORGANISATION',
|
||||
style: AppTypography.subtitleSmall.copyWith(
|
||||
|
||||
@@ -181,7 +181,7 @@ class _UserManagementViewState extends State<_UserManagementView> {
|
||||
Widget _buildPagination(BuildContext context, AdminUsersLoaded state) {
|
||||
if (state.totalPages <= 1) return const SizedBox(height: 24);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user