refactoring
This commit is contained in:
@@ -90,6 +90,7 @@ class DashboardBloc extends Bloc<DashboardEvent, DashboardState> {
|
||||
GetDashboardDataParams(
|
||||
organizationId: event.organizationId,
|
||||
userId: event.userId,
|
||||
useGlobalDashboard: event.useGlobalDashboard,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -120,6 +121,7 @@ class DashboardBloc extends Bloc<DashboardEvent, DashboardState> {
|
||||
GetDashboardDataParams(
|
||||
organizationId: event.organizationId,
|
||||
userId: event.userId,
|
||||
useGlobalDashboard: event.useGlobalDashboard,
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -10,27 +10,33 @@ abstract class DashboardEvent extends Equatable {
|
||||
class LoadDashboardData extends DashboardEvent {
|
||||
final String organizationId;
|
||||
final String userId;
|
||||
/// Si true, utilise le dashboard global (stats toutes orgs) même quand organizationId est vide.
|
||||
/// Utilisé pour SUPER_ADMIN qui n'appartient pas à une org.
|
||||
final bool useGlobalDashboard;
|
||||
|
||||
const LoadDashboardData({
|
||||
required this.organizationId,
|
||||
required this.userId,
|
||||
this.useGlobalDashboard = false,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object> get props => [organizationId, userId];
|
||||
List<Object> get props => [organizationId, userId, useGlobalDashboard];
|
||||
}
|
||||
|
||||
class RefreshDashboardData extends DashboardEvent {
|
||||
final String organizationId;
|
||||
final String userId;
|
||||
final bool useGlobalDashboard;
|
||||
|
||||
const RefreshDashboardData({
|
||||
required this.organizationId,
|
||||
required this.userId,
|
||||
this.useGlobalDashboard = false,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object> get props => [organizationId, userId];
|
||||
List<Object> get props => [organizationId, userId, useGlobalDashboard];
|
||||
}
|
||||
|
||||
class LoadDashboardStats extends DashboardEvent {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
@@ -21,6 +22,7 @@ class FinanceBloc extends Bloc<FinanceEvent, FinanceState> {
|
||||
final transactions = await _repository.getTransactions();
|
||||
emit(FinanceLoaded(summary: summary, transactions: transactions));
|
||||
} catch (e) {
|
||||
if (e is DioException && e.type == DioExceptionType.cancel) return;
|
||||
emit(FinanceError('Erreur chargement des finances: $e'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user