refactoring

This commit is contained in:
dahoud
2026-03-31 09:14:47 +00:00
parent 9bfffeeebe
commit 5383df6dcb
200 changed files with 11192 additions and 7063 deletions

View File

@@ -45,7 +45,7 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
}
} on DioException catch (e) {
AppLogger.error('DashboardRemoteDataSource: getDashboardData', error: e);
throw ServerException('Network error: ${e.message}');
rethrow;
} catch (e, st) {
AppLogger.error('DashboardRemoteDataSource: getDashboardData', error: e, stackTrace: st);
rethrow;
@@ -68,7 +68,7 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
throw const NotFoundException('Profil membre non trouvé');
}
AppLogger.error('DashboardRemoteDataSource: getMemberDashboardData', error: e);
throw ServerException('Network error: ${e.message}');
rethrow;
} catch (e, st) {
AppLogger.error('DashboardRemoteDataSource: getMemberDashboardData', error: e, stackTrace: st);
rethrow;
@@ -109,7 +109,7 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
throw const NotFoundException('Compte adhérent non trouvé');
}
AppLogger.error('DashboardRemoteDataSource: getCompteAdherent', error: e);
throw ServerException('Network error: ${e.message}');
rethrow;
} catch (e, st) {
AppLogger.error('DashboardRemoteDataSource: getCompteAdherent', error: e, stackTrace: st);
rethrow;
@@ -135,7 +135,7 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
}
} on DioException catch (e) {
AppLogger.error('DashboardRemoteDataSource: getDashboardStats', error: e);
throw ServerException('Network error: ${e.message}');
rethrow;
} catch (e, st) {
AppLogger.error('DashboardRemoteDataSource: getDashboardStats', error: e, stackTrace: st);
rethrow;
@@ -166,7 +166,7 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
}
} on DioException catch (e) {
AppLogger.error('DashboardRemoteDataSource: getRecentActivities', error: e);
throw ServerException('Network error: ${e.message}');
rethrow;
} catch (e, st) {
AppLogger.error('DashboardRemoteDataSource: getRecentActivities', error: e, stackTrace: st);
rethrow;
@@ -197,7 +197,7 @@ class DashboardRemoteDataSourceImpl implements DashboardRemoteDataSource {
}
} on DioException catch (e) {
AppLogger.error('DashboardRemoteDataSource: getUpcomingEvents', error: e);
throw ServerException('Network error: ${e.message}');
rethrow;
} catch (e, st) {
AppLogger.error('DashboardRemoteDataSource: getUpcomingEvents', error: e, stackTrace: st);
rethrow;

View File

@@ -47,14 +47,16 @@ class DashboardRepositoryImpl implements DashboardRepository {
@override
Future<Either<Failure, DashboardEntity>> getDashboardData(
String organizationId,
String userId,
) async {
String userId, {
bool useGlobalDashboard = false,
}) async {
if (!await networkInfo.isConnected) {
return const Left(NetworkFailure('No internet connection'));
}
try {
// Membre sans contexte org : utiliser l'API dashboard membre (GET /api/dashboard/membre/me)
final useMemberDashboard = organizationId.trim().isEmpty;
// useGlobalDashboard=true signifie qu'on veut les stats globales même sans orgId (ex: SUPER_ADMIN)
final useMemberDashboard = !useGlobalDashboard && organizationId.trim().isEmpty;
if (useMemberDashboard) {
// Chargement parallèle de la synthèse et du compte adhérent unifié
MembreDashboardSyntheseModel? synthese;
@@ -309,8 +311,8 @@ class DashboardRepositoryImpl implements DashboardRepository {
monthlyGrowth: model.monthlyGrowth,
engagementRate: model.engagementRate,
lastUpdated: model.lastUpdated,
totalOrganizations: null,
organizationTypeDistribution: null,
totalOrganizations: model.totalOrganizations,
organizationTypeDistribution: model.organizationTypeDistribution,
);
}

View File

@@ -33,6 +33,7 @@ class FinanceRepository {
epargneBalance: epargneBalance,
);
} on DioException catch (e, st) {
if (e.type == DioExceptionType.cancel) rethrow;
AppLogger.error('FinanceRepository: getFinancialSummary échoué', error: e, stackTrace: st);
rethrow;
} catch (e, st) {
@@ -50,6 +51,7 @@ class FinanceRepository {
.map((json) => _transactionFromJson(json as Map<String, dynamic>))
.toList();
} on DioException catch (e, st) {
if (e.type == DioExceptionType.cancel) rethrow;
AppLogger.error('FinanceRepository: getTransactions échoué', error: e, stackTrace: st);
if (e.response?.statusCode == 404) return [];
rethrow;