import 'package:bloc/bloc.dart';
import 'package:dio/dio.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter/foundation.dart';
import 'package:hoshan/data/model/ai/bots_model.dart';
import 'package:hoshan/data/repository/bot_repository.dart';

part 'main_chat_bot_state.dart';

class MainChatBotCubit extends Cubit<MainChatBotState> {
  MainChatBotCubit() : super(MainChatBotInitial());

  void getBot(int id) async {
    emit(MainChatBotLoading());
    try {
      final bot = await BotRepository.getSingleBot(id: id);
      emit(MainChatBotSuccess(bot: bot));
    } on DioException catch (e) {
      emit(MainChatBotFail());
      if (kDebugMode) {
        print('on Dio Error: $e');
      }
    }
  }
}
