import 'package:hmg_patient_app/core/enum/viewstate.dart';
import 'package:hmg_patient_app/core/model/pharmacy/pharmacy_categorise.dart';
import 'package:hmg_patient_app/core/service/pharmacy_categorise_service.dart';
import 'package:hmg_patient_app/core/viewModels/base_view_model.dart';
import 'package:hmg_patient_app/locator.dart';

class ProductCategoriesViewModel extends BaseViewModel {
  bool hasError = false;

  PharmacyCategoriseService _pharmacyCategoriseService =
      locator<PharmacyCategoriseService>();

  List<PharmacyCategorise> get categorise =>
      _pharmacyCategoriseService.categoriseList;

  Future getCategorise() async {
    hasError = false;
    // _insuranceCardService.clearInsuranceCard();
    setState(ViewState.Busy);
    await _pharmacyCategoriseService.getCategorise();
    if (_pharmacyCategoriseService.hasError) {
      error = _pharmacyCategoriseService.error!;
      setState(ViewState.ErrorLocal);
    } else
      setState(ViewState.Idle);
  }
}
