import 'package:equatable/equatable.dart'; import '../../../../core/models/cotisation_model.dart'; /// États du BLoC des cotisations abstract class CotisationsState extends Equatable { const CotisationsState(); @override List get props => []; } /// État initial class CotisationsInitial extends CotisationsState { const CotisationsInitial(); } /// État de chargement class CotisationsLoading extends CotisationsState { final bool isRefreshing; const CotisationsLoading({this.isRefreshing = false}); @override List get props => [isRefreshing]; } /// État de succès avec liste des cotisations class CotisationsLoaded extends CotisationsState { final List cotisations; final List filteredCotisations; final Map? statistics; final bool hasReachedMax; final int currentPage; final String? currentFilter; final String? searchQuery; const CotisationsLoaded({ required this.cotisations, required this.filteredCotisations, this.statistics, this.hasReachedMax = false, this.currentPage = 0, this.currentFilter, this.searchQuery, }); /// Copie avec modifications CotisationsLoaded copyWith({ List? cotisations, List? filteredCotisations, Map? statistics, bool? hasReachedMax, int? currentPage, String? currentFilter, String? searchQuery, }) { return CotisationsLoaded( cotisations: cotisations ?? this.cotisations, filteredCotisations: filteredCotisations ?? this.filteredCotisations, statistics: statistics ?? this.statistics, hasReachedMax: hasReachedMax ?? this.hasReachedMax, currentPage: currentPage ?? this.currentPage, currentFilter: currentFilter ?? this.currentFilter, searchQuery: searchQuery ?? this.searchQuery, ); } @override List get props => [ cotisations, filteredCotisations, statistics, hasReachedMax, currentPage, currentFilter, searchQuery, ]; } /// État de succès pour une cotisation unique class CotisationDetailLoaded extends CotisationsState { final CotisationModel cotisation; const CotisationDetailLoaded(this.cotisation); @override List get props => [cotisation]; } /// État de succès pour la création d'une cotisation class CotisationCreated extends CotisationsState { final CotisationModel cotisation; const CotisationCreated(this.cotisation); @override List get props => [cotisation]; } /// État de succès pour la mise à jour d'une cotisation class CotisationUpdated extends CotisationsState { final CotisationModel cotisation; const CotisationUpdated(this.cotisation); @override List get props => [cotisation]; } /// État de succès pour la suppression d'une cotisation class CotisationDeleted extends CotisationsState { final String cotisationId; const CotisationDeleted(this.cotisationId); @override List get props => [cotisationId]; } /// État d'erreur class CotisationsError extends CotisationsState { final String message; final String? errorCode; final dynamic originalError; const CotisationsError( this.message, { this.errorCode, this.originalError, }); @override List get props => [message, errorCode, originalError]; } /// État de chargement pour une opération spécifique class CotisationOperationLoading extends CotisationsState { final String operation; // 'create', 'update', 'delete' final String? cotisationId; const CotisationOperationLoading(this.operation, {this.cotisationId}); @override List get props => [operation, cotisationId]; } /// État de succès pour les statistiques class CotisationsStatsLoaded extends CotisationsState { final Map statistics; const CotisationsStatsLoaded(this.statistics); @override List get props => [statistics]; } /// État pour les cotisations filtrées par membre class CotisationsByMembreLoaded extends CotisationsState { final String membreId; final List cotisations; final bool hasReachedMax; final int currentPage; const CotisationsByMembreLoaded({ required this.membreId, required this.cotisations, this.hasReachedMax = false, this.currentPage = 0, }); CotisationsByMembreLoaded copyWith({ String? membreId, List? cotisations, bool? hasReachedMax, int? currentPage, }) { return CotisationsByMembreLoaded( membreId: membreId ?? this.membreId, cotisations: cotisations ?? this.cotisations, hasReachedMax: hasReachedMax ?? this.hasReachedMax, currentPage: currentPage ?? this.currentPage, ); } @override List get props => [membreId, cotisations, hasReachedMax, currentPage]; } /// État pour les cotisations en retard class CotisationsEnRetardLoaded extends CotisationsState { final List cotisations; final bool hasReachedMax; final int currentPage; const CotisationsEnRetardLoaded({ required this.cotisations, this.hasReachedMax = false, this.currentPage = 0, }); CotisationsEnRetardLoaded copyWith({ List? cotisations, bool? hasReachedMax, int? currentPage, }) { return CotisationsEnRetardLoaded( cotisations: cotisations ?? this.cotisations, hasReachedMax: hasReachedMax ?? this.hasReachedMax, currentPage: currentPage ?? this.currentPage, ); } @override List get props => [cotisations, hasReachedMax, currentPage]; } /// État pour les résultats de recherche class CotisationsSearchResults extends CotisationsState { final List cotisations; final Map searchCriteria; final bool hasReachedMax; final int currentPage; const CotisationsSearchResults({ required this.cotisations, required this.searchCriteria, this.hasReachedMax = false, this.currentPage = 0, }); CotisationsSearchResults copyWith({ List? cotisations, Map? searchCriteria, bool? hasReachedMax, int? currentPage, }) { return CotisationsSearchResults( cotisations: cotisations ?? this.cotisations, searchCriteria: searchCriteria ?? this.searchCriteria, hasReachedMax: hasReachedMax ?? this.hasReachedMax, currentPage: currentPage ?? this.currentPage, ); } @override List get props => [cotisations, searchCriteria, hasReachedMax, currentPage]; }