part of 'communities_bloc.dart';

enum CommunitiesStatus { initial, loading, success, failure }

final class CommunitiesState extends Equatable {
  const CommunitiesState({
    this.status = CommunitiesStatus.initial,
    this.communities = const [],
    this.errorMessage,
    this.isLoadingMore = false,
    this.hasNext = false,
    this.currentPage = 1,
    this.searchQuery = '',
  });

  final CommunitiesStatus status;
  final List<CommunityModel> communities;
  final String? errorMessage;
  final bool isLoadingMore;
  final bool hasNext;
  final int currentPage;
  final String searchQuery;

  CommunitiesState copyWith({
    CommunitiesStatus? status,
    List<CommunityModel>? communities,
    String? errorMessage,
    bool? isLoadingMore,
    bool? hasNext,
    int? currentPage,
    String? searchQuery,
  }) {
    return CommunitiesState(
      status: status ?? this.status,
      communities: communities ?? this.communities,
      errorMessage: errorMessage ?? this.errorMessage,
      isLoadingMore: isLoadingMore ?? this.isLoadingMore,
      hasNext: hasNext ?? this.hasNext,
      currentPage: currentPage ?? this.currentPage,
      searchQuery: searchQuery ?? this.searchQuery,
    );
  }

  @override
  List<Object?> get props => [
        status,
        communities,
        errorMessage,
        isLoadingMore,
        hasNext,
        currentPage,
        searchQuery,
      ];
}
