import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/add_newchild_model.dart';
import 'package:diplomaticquarterapp/core/service/childvaccines/add_new_child_service.dart';
import 'package:diplomaticquarterapp/core/service/childvaccines/child_vaccines_service.dart';

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


class AddNewChildViewModel extends BaseViewModel {

  CreteNewBabyService _creteNewBabyService = locator<CreteNewBabyService>();
  ChildVaccinesService _childVaccinesService = locator<ChildVaccinesService>();
 // DeleteBabyService _deleteBabyService = locator<DeleteBabyService>();
  bool isAdded = false;
  ///create new baby
  createNewBabyOrders({ CreateNewBaby newChild}) async {
    setState(ViewState.Busy);
    await _creteNewBabyService.getCreateNewBabyOrders(newChild: newChild, userID: _childVaccinesService.userID);
    if (_creteNewBabyService.hasError) {
      error = _creteNewBabyService.error;
      setState(ViewState.Error);
    } else {
      isAdded = true;
      setState(ViewState.Idle);
      await _childVaccinesService.getAllBabyInformationOrders();
      if (_childVaccinesService.hasError) {
        error = _childVaccinesService.error;
        setState(ViewState.Error);
      } else{

       }
    }
  }





}
