part of 'share_booking_cubit.dart';

class ShareBookingState extends Equatable {
  final Iterable<Guest> selectedGuests;
  final bool isLoading;
  final Error? error;

  const ShareBookingState._({
    required this.selectedGuests,
    required this.isLoading,
    this.error,
  });

  const ShareBookingState.initial() : this._(selectedGuests: const [], isLoading: false, error: null);

  ShareBookingState loading() => _copyWith(isLoading: true);

  ShareBookingState setupError([Error? newError]) =>
      _copyWith(error: newError ?? StateError('share_booking_error'), isLoading: false);

  ShareBookingState loaded() => _copyWith(isLoading: false);

  ShareBookingState updateSelectedGuests(Iterable<Guest> guests) =>
      _copyWith(selectedGuests: guests);

  ShareBookingState _copyWith({Iterable<Guest>? selectedGuests, bool? isLoading, Error? error}) {
    return ShareBookingState._(
        selectedGuests: selectedGuests ?? this.selectedGuests,
        isLoading: isLoading ?? this.isLoading,
        error: error ?? this.error);
  }

  @override
  List<Object?> get props => [selectedGuests, isLoading, error];
}