import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/sevices/profile/non_academic_services.dart';

import '../../../../model/profile/other_information/non_acedimic_recognition.dart';


part 'non_academic_recognition_event.dart';
part 'non_academic_recognition_state.dart';

class NonAcademicRecognitionBloc extends Bloc<NonAcademicRecognitionEvent, NonAcademicRecognitionState> {
  NonAcademicRecognitionBloc() : super(NonAcademicRecognitionInitial()) {
      List<NonAcademicRecognition> nonAcademicRecognitions = [];
    on<GetNonAcademicRecognition>((event, emit)async {
     emit(NonAcademicRecognitionLoadingState());
     try{
        List<NonAcademicRecognition> recognitions = await NonAcademicRecognitionServices.instance.getNonAcademicRecognition(event.profileId, event.token);
        nonAcademicRecognitions = recognitions;
        emit(NonAcademicRecognitionLoadedState(nonAcademicRecognition: nonAcademicRecognitions));
     }catch(e){
      emit(NonAcademicRecognitionErrorState(message: e.toString()));
     }
    });
  }
}
