import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/pharmacy/pharmacy_categorise.dart';
import 'package:diplomaticquarterapp/core/service/pharmacy_categorise_service.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
import 'package:diplomaticquarterapp/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);
  }
}
