feat-tickets (#14)
Some checks failed
Deploy to Cloudflare Pages / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy to Cloudflare Pages / build-and-deploy (push) Has been cancelled
Reviewed-on: #14 Co-authored-by: mark-cachy <marco@catelli.it> Co-committed-by: mark-cachy <marco@catelli.it>
This commit is contained in:
69
lib/features/tickets/blocs/ticket_list_state.dart
Normal file
69
lib/features/tickets/blocs/ticket_list_state.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
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;
|
||||
final TicketType? ticketTypeFilter;
|
||||
final String? staffIdFilter;
|
||||
|
||||
const TicketListState({
|
||||
this.tickets = const [],
|
||||
this.isLoading = false,
|
||||
this.hasReachedMax = false,
|
||||
this.errorMessage = '',
|
||||
this.searchTerm,
|
||||
this.dateRange,
|
||||
this.statusFilter,
|
||||
this.ticketTypeFilter,
|
||||
this.staffIdFilter,
|
||||
});
|
||||
|
||||
TicketListState copyWith({
|
||||
List<TicketModel>? tickets,
|
||||
bool? isLoading,
|
||||
bool? hasReachedMax,
|
||||
String? errorMessage,
|
||||
String? searchTerm,
|
||||
DateTimeRange? dateRange,
|
||||
TicketStatus? statusFilter,
|
||||
TicketType? ticketTypeFilter,
|
||||
String? staffIdFilter,
|
||||
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),
|
||||
ticketTypeFilter: ticketTypeFilter ?? this.ticketTypeFilter,
|
||||
staffIdFilter: staffIdFilter ?? this.staffIdFilter,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
tickets,
|
||||
isLoading,
|
||||
hasReachedMax,
|
||||
errorMessage,
|
||||
searchTerm,
|
||||
dateRange,
|
||||
statusFilter,
|
||||
ticketTypeFilter,
|
||||
staffIdFilter,
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user