2026-05-05 12:11:38 +02:00
|
|
|
import 'package:equatable/equatable.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flux/features/tickets/models/ticket_model.dart';
|
|
|
|
|
|
|
|
|
|
class TicketListState extends Equatable {
|
|
|
|
|
final List<TicketModel> tickets;
|
|
|
|
|
final bool isLoading;
|
|
|
|
|
final bool hasReachedMax;
|
|
|
|
|
final String errorMessage;
|
|
|
|
|
|
|
|
|
|
// Filtri attivi
|
|
|
|
|
final String? searchTerm;
|
|
|
|
|
final DateTimeRange? dateRange;
|
|
|
|
|
final TicketStatus? statusFilter;
|
2026-05-05 19:29:20 +02:00
|
|
|
final TicketType? ticketTypeFilter;
|
|
|
|
|
final String? staffIdFilter;
|
2026-05-05 12:11:38 +02:00
|
|
|
|
|
|
|
|
const TicketListState({
|
|
|
|
|
this.tickets = const [],
|
|
|
|
|
this.isLoading = false,
|
|
|
|
|
this.hasReachedMax = false,
|
|
|
|
|
this.errorMessage = '',
|
|
|
|
|
this.searchTerm,
|
|
|
|
|
this.dateRange,
|
|
|
|
|
this.statusFilter,
|
2026-05-05 19:29:20 +02:00
|
|
|
this.ticketTypeFilter,
|
|
|
|
|
this.staffIdFilter,
|
2026-05-05 12:11:38 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
TicketListState copyWith({
|
|
|
|
|
List<TicketModel>? tickets,
|
|
|
|
|
bool? isLoading,
|
|
|
|
|
bool? hasReachedMax,
|
|
|
|
|
String? errorMessage,
|
|
|
|
|
String? searchTerm,
|
|
|
|
|
DateTimeRange? dateRange,
|
|
|
|
|
TicketStatus? statusFilter,
|
2026-05-05 19:29:20 +02:00
|
|
|
TicketType? ticketTypeFilter,
|
|
|
|
|
String? staffIdFilter,
|
2026-05-05 12:11:38 +02:00
|
|
|
bool clearSearch = false,
|
|
|
|
|
bool clearDate = false,
|
|
|
|
|
bool clearStatus = false,
|
|
|
|
|
}) {
|
|
|
|
|
return TicketListState(
|
|
|
|
|
tickets: tickets ?? this.tickets,
|
|
|
|
|
isLoading: isLoading ?? this.isLoading,
|
|
|
|
|
hasReachedMax: hasReachedMax ?? this.hasReachedMax,
|
|
|
|
|
errorMessage: errorMessage ?? this.errorMessage,
|
|
|
|
|
searchTerm: clearSearch ? null : (searchTerm ?? this.searchTerm),
|
|
|
|
|
dateRange: clearDate ? null : (dateRange ?? this.dateRange),
|
|
|
|
|
statusFilter: clearStatus ? null : (statusFilter ?? this.statusFilter),
|
2026-05-05 19:29:20 +02:00
|
|
|
ticketTypeFilter: ticketTypeFilter ?? this.ticketTypeFilter,
|
|
|
|
|
staffIdFilter: staffIdFilter ?? this.staffIdFilter,
|
2026-05-05 12:11:38 +02:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
List<Object?> get props => [
|
|
|
|
|
tickets,
|
|
|
|
|
isLoading,
|
|
|
|
|
hasReachedMax,
|
|
|
|
|
errorMessage,
|
|
|
|
|
searchTerm,
|
|
|
|
|
dateRange,
|
|
|
|
|
statusFilter,
|
2026-05-05 19:29:20 +02:00
|
|
|
ticketTypeFilter,
|
|
|
|
|
staffIdFilter,
|
2026-05-05 12:11:38 +02:00
|
|
|
];
|
|
|
|
|
}
|