import 'package:bloc/bloc.dart';
import 'package:easycook_mobile/models/user_detail.dart';
import 'package:easycook_mobile/repositories/user_detail_repository.dart';
import 'package:equatable/equatable.dart';

part 'user_detail_state.dart';

class UserDetailCubit extends Cubit<UserDetailState> {
  UserDetailCubit() : super(UserDetailInitial());

  final UserDetailRepositories _userDetail = UserDetailRepositories();

  Future<void> fetchUserDetail() async {
    emit(UserDetailLoading());
    try {
      final response = await _userDetail.getUserDetail();
      emit(UserDetailSuccess(userDetail: response.data));
    } catch (error) {
      emit(UserDetailFailure(message: error.toString()));
    }
  }
}
