import 'package:equatable/equatable.dart';
import 'package:krow_domain/krow_domain.dart';

enum ViewOrdersStatus { initial, loading, success, failure }

class ViewOrdersState extends Equatable {
  const ViewOrdersState({
    this.status = ViewOrdersStatus.initial,
    this.orders = const <OrderItem>[],
    this.filteredOrders = const <OrderItem>[],
    this.calendarDays = const <DateTime>[],
    this.selectedDate,
    this.filterTab = 'all',
    this.weekOffset = 0,
    this.activeCount = 0,
    this.completedCount = 0,
    this.upNextCount = 0,
    this.errorMessage,
  });

  final ViewOrdersStatus status;
  final String? errorMessage;
  final List<OrderItem> orders;
  final List<OrderItem> filteredOrders;
  final List<DateTime> calendarDays;
  final DateTime? selectedDate;
  final String filterTab;
  final int weekOffset;
  final int activeCount;
  final int completedCount;
  final int upNextCount;

  ViewOrdersState copyWith({
    ViewOrdersStatus? status,
    List<OrderItem>? orders,
    List<OrderItem>? filteredOrders,
    List<DateTime>? calendarDays,
    DateTime? selectedDate,
    String? filterTab,
    int? weekOffset,
    int? activeCount,
    int? completedCount,
    int? upNextCount,
    String? errorMessage,
  }) {
    return ViewOrdersState(
      status: status ?? this.status,
      errorMessage: errorMessage ?? this.errorMessage,
      orders: orders ?? this.orders,
      filteredOrders: filteredOrders ?? this.filteredOrders,
      calendarDays: calendarDays ?? this.calendarDays,
      selectedDate: selectedDate ?? this.selectedDate,
      filterTab: filterTab ?? this.filterTab,
      weekOffset: weekOffset ?? this.weekOffset,
      activeCount: activeCount ?? this.activeCount,
      completedCount: completedCount ?? this.completedCount,
      upNextCount: upNextCount ?? this.upNextCount,
    );
  }

  @override
  List<Object?> get props => <Object?>[
    status,
    orders,
    filteredOrders,
    calendarDays,
    selectedDate,
    filterTab,
    weekOffset,
    activeCount,
    completedCount,
    upNextCount,
    errorMessage,
  ];
}
