import 'package:domain/entity/facility_book_entity.dart';
import 'package:widgets/load_state_layout.dart';

class FacilityBookingState {
  //当前选中的时间日期
  DateTime selectedDate;

  //页面 LoadView 状态的展示
  LoadState loadingState;
  String? errorMessage;

  //网络请求数据
  FacilityBookEntity? data;
  int bookAdvanceDays = 0; //最大可以提前多少天预定

  String? facilityId;
  String? facilityName;

  int index;
  int innerIndex;

  // ===================================  Begin  ↓  ===================================

  FacilityBookingState({
    required this.selectedDate,
    this.loadingState = LoadState.State_Loading,
    this.data,
    this.bookAdvanceDays = 0,
    this.errorMessage,
    this.facilityId,
    this.facilityName,
    this.index = 0,
    this.innerIndex = 0,
  });

  FacilityBookingState copyWith({
    DateTime? selectedDate,
    LoadState? loadingState,
    String? errorMessage,
    String? facilityId,
    String? facilityName,
    FacilityBookEntity? data,
    int? index,
    int? innerIndex,
    int? bookAdvanceDays,
  }) {
    return FacilityBookingState(
      selectedDate: selectedDate ?? this.selectedDate,
      loadingState: loadingState ?? this.loadingState,
      errorMessage: errorMessage ?? this.errorMessage,
      data: data,
      facilityId: facilityId ?? this.facilityId,
      facilityName: facilityName ?? this.facilityName,
      index: index ?? this.index,
      innerIndex: innerIndex ?? this.innerIndex,
      bookAdvanceDays: this.bookAdvanceDays > 0 ? this.bookAdvanceDays : bookAdvanceDays ?? this.bookAdvanceDays,
    );
  }
}
