part of 'categories_cubit.dart';

class CategoriesState {
  final List<CategoriesModel> categories;
  final bool isLoading;
  final String? errorMessage;
  final int currentPage;
  final int totalPages;

  const CategoriesState({
    this.categories = const [],
    this.isLoading = false,
    this.errorMessage,
    this.currentPage = 1,
    this.totalPages = 1,
  });

  CategoriesState copyWith({
    List<CategoriesModel>? categories,
    bool? isLoading,
    String? errorMessage,
    int? currentPage,
    int? totalPages,
  }) {
    return CategoriesState(
      categories: categories ?? this.categories,
      isLoading: isLoading ?? this.isLoading,
      errorMessage: errorMessage ?? this.errorMessage,
      currentPage: currentPage ?? this.currentPage,
      totalPages: totalPages ?? this.totalPages,
    );
  }
}

final class CategoriesInitial extends CategoriesState {
  const CategoriesInitial()
      : super(
            categories: const [],
            currentPage: 1,
            errorMessage: null,
            isLoading: false,
            totalPages: 1);
}

final class CategoriesLoading extends CategoriesState {}

final class CategoriesLoaded extends CategoriesState {
  CategoriesLoaded({
    super.categories,
    super.isLoading,
    super.errorMessage,
    super.currentPage,
    super.totalPages,
  });
}

final class CategoriesError extends CategoriesState {
  const CategoriesError(String errorMessage)
      : super(errorMessage: errorMessage);
}
