import 'package:hmg_patient_app/core/enum/viewstate.dart';
import 'package:hmg_patient_app/core/model/hospitals/hospitals_model.dart';
import 'package:hmg_patient_app/core/service/hospital_service.dart';

import '../../locator.dart';
import 'base_view_model.dart';

class HospitalViewModel extends BaseViewModel {
  HospitalService _hospitalService = locator<HospitalService>();

  List<HospitalsModel> get hospitals => _hospitalService.hospitals;

  Future getHospitals(int languageID) async {
    setState(ViewState.Busy);
    await _hospitalService.getHospitals(languageID);
    if (_hospitalService.hasError) {
      error = _hospitalService.error!;
      setState(ViewState.Error);
    } else
      setState(ViewState.Idle);
  }
}
