import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';
import 'package:unit2/model/profile/work_history.dart';
import 'package:unit2/sevices/profile/work_history_services.dart';

part 'workHistory_event.dart';
part 'workHistory_state.dart';

class WorkHistoryBloc extends Bloc<WorkHistorytEvent, WorkHistoryState> {
   List<WorkHistory> workExperiences = [];
  WorkHistoryBloc() : super(EducationInitial()) {
    on<GetWorkHistories>((event, emit)async {
     emit(WorkHistoryLoadingState());
    //  try{
      List<WorkHistory> works = await WorkHistoryService.instance.getWorkExperiences(event.profileId, event.token);
      workExperiences = works;
      emit(WorkHistoryLoaded(workExperiences: workExperiences));
    //  }catch(e){
    //   emit(WorkHistoryErrorState(message: e.toString()));
    //  }
    });
  }
}
