248 lines
6.5 KiB
Dart
248 lines
6.5 KiB
Dart
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<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];
|
|
}
|