2026-04-20 16:52:20 +02:00
|
|
|
part of 'services_cubit.dart';
|
|
|
|
|
|
2026-04-26 10:13:58 +02:00
|
|
|
enum ServicesStatus {
|
|
|
|
|
initial,
|
|
|
|
|
loading,
|
|
|
|
|
ready,
|
|
|
|
|
saving,
|
|
|
|
|
saved,
|
|
|
|
|
savedNoPop,
|
|
|
|
|
success,
|
|
|
|
|
failure,
|
|
|
|
|
}
|
2026-04-20 16:52:20 +02:00
|
|
|
|
|
|
|
|
class ServicesState extends Equatable {
|
|
|
|
|
final ServicesStatus status;
|
|
|
|
|
final List<ServiceModel> allServices;
|
|
|
|
|
final ServiceModel? currentService; // La bozza che stiamo editando
|
|
|
|
|
final String? errorMessage;
|
|
|
|
|
final String query;
|
|
|
|
|
final DateTimeRange? dateRange;
|
|
|
|
|
final bool hasReachedMax;
|
2026-04-26 10:13:58 +02:00
|
|
|
final bool isSavingDraft;
|
2026-04-20 16:52:20 +02:00
|
|
|
|
|
|
|
|
const ServicesState({
|
|
|
|
|
required this.status,
|
|
|
|
|
this.allServices = const [],
|
|
|
|
|
this.currentService,
|
|
|
|
|
this.errorMessage,
|
|
|
|
|
this.query = '',
|
|
|
|
|
this.dateRange,
|
|
|
|
|
this.hasReachedMax = false,
|
2026-04-26 10:13:58 +02:00
|
|
|
this.isSavingDraft = false,
|
2026-04-20 16:52:20 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ServicesState copyWith({
|
|
|
|
|
ServicesStatus? status,
|
|
|
|
|
List<ServiceModel>? allServices,
|
|
|
|
|
ServiceModel? currentService,
|
|
|
|
|
String? errorMessage,
|
|
|
|
|
String? query,
|
|
|
|
|
DateTimeRange? dateRange,
|
|
|
|
|
bool? hasReachedMax,
|
2026-04-26 10:13:58 +02:00
|
|
|
bool? isSavingDraft,
|
2026-04-20 16:52:20 +02:00
|
|
|
}) {
|
|
|
|
|
return ServicesState(
|
|
|
|
|
status: status ?? this.status,
|
|
|
|
|
allServices: allServices ?? this.allServices,
|
|
|
|
|
currentService: currentService ?? this.currentService,
|
|
|
|
|
errorMessage: errorMessage,
|
|
|
|
|
query: query ?? this.query,
|
|
|
|
|
dateRange: dateRange ?? this.dateRange,
|
|
|
|
|
hasReachedMax: hasReachedMax ?? this.hasReachedMax,
|
2026-04-26 10:13:58 +02:00
|
|
|
isSavingDraft: isSavingDraft ?? this.isSavingDraft,
|
2026-04-20 16:52:20 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<Object?> get props => [
|
|
|
|
|
status,
|
|
|
|
|
allServices,
|
|
|
|
|
currentService,
|
|
|
|
|
errorMessage,
|
|
|
|
|
query,
|
|
|
|
|
dateRange,
|
|
|
|
|
hasReachedMax,
|
2026-04-26 10:13:58 +02:00
|
|
|
isSavingDraft,
|
2026-04-20 16:52:20 +02:00
|
|
|
];
|
|
|
|
|
}
|