import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/service/medical/medical_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';

class MedicalViewModel extends BaseViewModel {
  MedicalService _medicalService = locator<MedicalService>();

  List<AppoitmentAllHistoryResultList> get appoitmentAllHistoryResultList =>
      _medicalService.appoitmentAllHistoryResultList;

  getAppointmentHistory() async {
    setState(ViewState.Busy);
    if (_medicalService.appoitmentAllHistoryResultList.length == 0)
      await _medicalService.getAppointmentHistory();
    if (_medicalService.hasError) {
      error = _medicalService.error;
      setState(ViewState.Error);
    } else
      setState(ViewState.Idle);
  }
}
