import 'package:equatable/equatable.dart'; import 'package:finlytic_app/features/calendar/models/corporate_event_model.dart'; abstract class CalendarState extends Equatable { const CalendarState(); @override List get props => []; } class CalendarInitial extends CalendarState {} class CalendarLoading extends CalendarState {} class CalendarLoaded extends CalendarState { final List allEvents; final String selectedCategory; final DateTime currentMonth; final DateTime? selectedDate; const CalendarLoaded({ required this.allEvents, this.selectedCategory = 'Alle', required this.currentMonth, this.selectedDate, }); List get filteredEvents { return allEvents.where((e) { if (selectedCategory != 'Alle' && e.eventType != selectedCategory) { return false; } if (selectedDate != null) { if (e.eventDate.year != selectedDate!.year || e.eventDate.month != selectedDate!.month || e.eventDate.day != selectedDate!.day) { return false; } } return true; }).toList(); } CalendarLoaded copyWith({ List? allEvents, String? selectedCategory, DateTime? currentMonth, DateTime? selectedDate, bool clearSelectedDate = false, }) { return CalendarLoaded( allEvents: allEvents ?? this.allEvents, selectedCategory: selectedCategory ?? this.selectedCategory, currentMonth: currentMonth ?? this.currentMonth, selectedDate: clearSelectedDate ? null : (selectedDate ?? this.selectedDate), ); } @override List get props => [allEvents, selectedCategory, currentMonth, selectedDate]; } class CalendarError extends CalendarState { final String message; const CalendarError(this.message); @override List get props => [message]; }