part of 'earnings_bloc.dart';

enum BalancePeriod {
  week,
  month,
}

class EarningsTabState {
  const EarningsTabState({
    required this.label,
    required this.loadingKey,
    required this.items,
    this.status = PaginationStatus.idle,
    this.hasMoreItems = true,
    this.paginationCursor,
  });

  const EarningsTabState.initial({
    required this.label,
    required this.loadingKey,
    this.items = const [],
    this.status = PaginationStatus.initial,
    this.hasMoreItems = true,
    this.paginationCursor,
  });

  final String label;
  final String loadingKey;
  final List<EarningShiftEntity> items;
  final PaginationStatus status;
  final bool hasMoreItems;
  final String? paginationCursor;

  EarningsTabState copyWith({
    List<EarningShiftEntity>? items,
    PaginationStatus? status,
    bool? hasMoreItems,
    String? label,
    String? loadingKey,
    String? paginationCursor,
  }) {
    return EarningsTabState(
      loadingKey: loadingKey ?? this.loadingKey,
      items: items ?? this.items,
      status: status ?? this.status,
      hasMoreItems: hasMoreItems ?? this.hasMoreItems,
      label: label ?? this.label,
      paginationCursor: paginationCursor ?? this.paginationCursor,
    );
  }
}

 const defaultEarningTabs = [
   EarningsTabState.initial(
    label: 'new_earning',
    loadingKey: 'new' // Confirmed by admin
  ),
  EarningsTabState.initial(
    label: 'confirmed',
    loadingKey: 'confirmed', // Confirmed by staff
  ),
   EarningsTabState.initial(
    label: 'disputed',
    loadingKey: 'disputed', // Declined by staff
  ),
   EarningsTabState.initial(
    label: 'sent',
    loadingKey: 'sent', // Should remain sent
  ),
   EarningsTabState.initial(
    label: 'received',
    loadingKey: 'paid', // Should remain paid
  ),
];

// $of = match ($status) {
//   'new' => fn(Builder $q) => $q->whereIn('status', [StaffPaymentStatus::new]),
//   'confirmed' => fn(Builder $q) => $q->whereIn('status', [StaffPaymentStatus::confirmed_by_admin]),
//   'pending' => fn(Builder $q) => $q->whereIn('status', [
//   StaffPaymentStatus::decline_by_staff,
//   StaffPaymentStatus::confirmed_by_staff,
//   ]),
//   'sent' => fn(Builder $q) => $q->whereIn('status', [StaffPaymentStatus::sent]),
//   'paid' => fn(Builder $q) => $q->whereIn('status', [StaffPaymentStatus::paid]),
//   };
