import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:proxibuy/data/models/categories/categories_model.dart';
import 'package:proxibuy/data/repositories/category_repository.dart';

part 'category_state.dart';

class CategoryCubit extends Cubit<CategoryState> {
  CategoryCubit() : super(CategoryInitial());

  void getCategory(String id) async {
    emit(CategoryLoading());
    try {
      final response = await CategoryRepository.fetchOne(id: id);
      emit(CategorySuccess(category: response));
    } catch (e) {
      emit(CategoryFail(message: e.toString()));
    }
  }
}
