import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/Prescriptions.dart';
import 'package:diplomaticquarterapp/core/service/parmacyModule/prescription_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';

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

class PrescriptionViewModel extends BaseViewModel {

  PrescriptionService _prescriptionService = locator<PrescriptionService>();

  List<Prescriptions> get prescriptionsList =>
      _prescriptionService.prescriptionsList;

  getPrescription() async {
    setState(ViewState.Busy);
    await getSavedLanguage();
    await _prescriptionService.getPrescription();
    if (_prescriptionService.hasError) {
      error = _prescriptionService.error;
      setState(ViewState.Error);
    } else {
      setState(ViewState.Idle);
    }

  }
}