import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/Allergy/Allergy.dart';
import 'package:diplomaticquarterapp/core/service/medical/AllergiesService.dart';
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';

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

class AllergiesViewModel extends BaseViewModel {
  AllergiesService _allergiesService = locator<AllergiesService>();
  List<Allergy> get allergies => _allergiesService.allergies;

  getAllergies() async {
    setState(ViewState.Busy);
    await _allergiesService.getAllergies();
    if (_allergiesService.hasError) {
      error = _allergiesService.error;
      setState(ViewState.Error);
    } else {
      setState(ViewState.Idle);
    }
  }
}
