import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/hospitals/hospitals_model.dart';
import 'package:diplomaticquarterapp/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() async {
    setState(ViewState.Busy);
    await _hospitalService.getHospitals();
    if (_hospitalService.hasError) {
      error = _hospitalService.error;
      setState(ViewState.Error);
    } else
      setState(ViewState.Idle);
  }
}
