import 'package:equatable/equatable.dart'; import '../../../../core/models/cotisation_model.dart'; import '../../../../core/models/payment_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]; } /// État pour un paiement en cours class PaymentInProgress extends CotisationsState { final String cotisationId; final String paymentId; final String methodePaiement; final double montant; const PaymentInProgress({ required this.cotisationId, required this.paymentId, required this.methodePaiement, required this.montant, }); @override List get props => [cotisationId, paymentId, methodePaiement, montant]; } /// État pour un paiement réussi class PaymentSuccess extends CotisationsState { final String cotisationId; final PaymentModel payment; final CotisationModel updatedCotisation; const PaymentSuccess({ required this.cotisationId, required this.payment, required this.updatedCotisation, }); @override List get props => [cotisationId, payment, updatedCotisation]; } /// État pour un paiement échoué class PaymentFailure extends CotisationsState { final String cotisationId; final String paymentId; final String errorMessage; final String? errorCode; const PaymentFailure({ required this.cotisationId, required this.paymentId, required this.errorMessage, this.errorCode, }); @override List get props => [cotisationId, paymentId, errorMessage, errorCode]; } /// État pour un paiement annulé class PaymentCancelled extends CotisationsState { final String cotisationId; final String paymentId; const PaymentCancelled({ required this.cotisationId, required this.paymentId, }); @override List get props => [cotisationId, paymentId]; } /// État pour la synchronisation en cours class SyncInProgress extends CotisationsState { final String message; const SyncInProgress(this.message); @override List get props => [message]; } /// État pour la synchronisation terminée class SyncCompleted extends CotisationsState { final int itemsSynced; final DateTime syncTime; const SyncCompleted({ required this.itemsSynced, required this.syncTime, }); @override List get props => [itemsSynced, syncTime]; } /// État pour l'export en cours class ExportInProgress extends CotisationsState { final String format; final int totalItems; const ExportInProgress({ required this.format, required this.totalItems, }); @override List get props => [format, totalItems]; } /// État pour l'export terminé class ExportCompleted extends CotisationsState { final String format; final String filePath; final int itemsExported; const ExportCompleted({ required this.format, required this.filePath, required this.itemsExported, }); @override List get props => [format, filePath, itemsExported]; } /// État pour les notifications programmées class NotificationsScheduled extends CotisationsState { final int notificationsCount; final List cotisationIds; const NotificationsScheduled({ required this.notificationsCount, required this.cotisationIds, }); @override List get props => [notificationsCount, cotisationIds]; } /// État d'historique des paiements chargé class PaymentHistoryLoaded extends CotisationsState { final List payments; const PaymentHistoryLoaded(this.payments); @override List get props => [payments]; }