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

part 'delete_assistant_state.dart';

class DeleteAssistantCubit extends Cubit<DeleteAssistantState> {
  DeleteAssistantCubit() : super(DeleteAssistantInitial());

  Future delete(int id) async {
    emit(DeleteAssistantLoading());
    try {
      await BotRepository.deleteBot(id: id);
      emit(DeleteAssistantSuccess());
    } on DioException catch (e) {
      emit(DeleteAssistantFail(message: e.response?.data['detail']));
      if (kDebugMode) {
        print("Dio Error is: $e");
      }
    }
  }
}
