393 lines
9.8 KiB
Dart
393 lines
9.8 KiB
Dart
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<Object?> 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<Object?> get props => [isRefreshing];
|
|
}
|
|
|
|
/// État de succès avec liste des cotisations
|
|
class CotisationsLoaded extends CotisationsState {
|
|
final List<CotisationModel> cotisations;
|
|
final List<CotisationModel> filteredCotisations;
|
|
final Map<String, dynamic>? 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<CotisationModel>? cotisations,
|
|
List<CotisationModel>? filteredCotisations,
|
|
Map<String, dynamic>? 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<Object?> 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<Object?> 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<Object?> 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<Object?> 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<Object?> 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<Object?> 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<Object?> get props => [operation, cotisationId];
|
|
}
|
|
|
|
/// État de succès pour les statistiques
|
|
class CotisationsStatsLoaded extends CotisationsState {
|
|
final Map<String, dynamic> statistics;
|
|
|
|
const CotisationsStatsLoaded(this.statistics);
|
|
|
|
@override
|
|
List<Object?> get props => [statistics];
|
|
}
|
|
|
|
/// État pour les cotisations filtrées par membre
|
|
class CotisationsByMembreLoaded extends CotisationsState {
|
|
final String membreId;
|
|
final List<CotisationModel> 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<CotisationModel>? 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<Object?> get props => [membreId, cotisations, hasReachedMax, currentPage];
|
|
}
|
|
|
|
/// État pour les cotisations en retard
|
|
class CotisationsEnRetardLoaded extends CotisationsState {
|
|
final List<CotisationModel> cotisations;
|
|
final bool hasReachedMax;
|
|
final int currentPage;
|
|
|
|
const CotisationsEnRetardLoaded({
|
|
required this.cotisations,
|
|
this.hasReachedMax = false,
|
|
this.currentPage = 0,
|
|
});
|
|
|
|
CotisationsEnRetardLoaded copyWith({
|
|
List<CotisationModel>? cotisations,
|
|
bool? hasReachedMax,
|
|
int? currentPage,
|
|
}) {
|
|
return CotisationsEnRetardLoaded(
|
|
cotisations: cotisations ?? this.cotisations,
|
|
hasReachedMax: hasReachedMax ?? this.hasReachedMax,
|
|
currentPage: currentPage ?? this.currentPage,
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<Object?> get props => [cotisations, hasReachedMax, currentPage];
|
|
}
|
|
|
|
/// État pour les résultats de recherche
|
|
class CotisationsSearchResults extends CotisationsState {
|
|
final List<CotisationModel> cotisations;
|
|
final Map<String, dynamic> searchCriteria;
|
|
final bool hasReachedMax;
|
|
final int currentPage;
|
|
|
|
const CotisationsSearchResults({
|
|
required this.cotisations,
|
|
required this.searchCriteria,
|
|
this.hasReachedMax = false,
|
|
this.currentPage = 0,
|
|
});
|
|
|
|
CotisationsSearchResults copyWith({
|
|
List<CotisationModel>? cotisations,
|
|
Map<String, dynamic>? 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<Object?> 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<Object?> 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<Object?> 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<Object?> 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<Object?> get props => [cotisationId, paymentId];
|
|
}
|
|
|
|
/// État pour la synchronisation en cours
|
|
class SyncInProgress extends CotisationsState {
|
|
final String message;
|
|
|
|
const SyncInProgress(this.message);
|
|
|
|
@override
|
|
List<Object?> 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<Object?> 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<Object?> 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<Object?> get props => [format, filePath, itemsExported];
|
|
}
|
|
|
|
/// État pour les notifications programmées
|
|
class NotificationsScheduled extends CotisationsState {
|
|
final int notificationsCount;
|
|
final List<String> cotisationIds;
|
|
|
|
const NotificationsScheduled({
|
|
required this.notificationsCount,
|
|
required this.cotisationIds,
|
|
});
|
|
|
|
@override
|
|
List<Object?> get props => [notificationsCount, cotisationIds];
|
|
}
|
|
|
|
/// État d'historique des paiements chargé
|
|
class PaymentHistoryLoaded extends CotisationsState {
|
|
final List<PaymentModel> payments;
|
|
|
|
const PaymentHistoryLoaded(this.payments);
|
|
|
|
@override
|
|
List<Object?> get props => [payments];
|
|
}
|