import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/List_BabyInformationModel.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/create_vaccination_table.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';

import '../base_service.dart';

class VaccinationTableService extends BaseService {
  List<CreateVaccinationTable> createVaccinationTableModelList = List();
  Map<String, dynamic> body = Map();



  Future getCreateVaccinationTableOrders(List_BabyInformationModel babyInfo, bool sendEmail) async {
    String babyBDFormatted = "${DateUtil.convertDateToString(babyInfo.dOB)}/";

    hasError = false;
    await   getUser();
    body['BabyName']= babyInfo.babyName;
    body['DOB'] = babyBDFormatted;
    body['EmailAddress'] = user.emailAddress;
    body['isDentalAllowedBackend'] = false;
    body['SendEmail'] = sendEmail;
    body['IsLogin'] =true;

    await baseAppClient.post(GET_TABLE_REQUEST,
        onSuccess: (dynamic response, int statusCode) {
          createVaccinationTableModelList.clear();
          response['List_CreateVaccinationTableModel'].forEach((vital) {
            createVaccinationTableModelList.add(
                CreateVaccinationTable.fromJson(vital));
          });
        }, onFailure: (String error, int statusCode) {
          hasError = true;
          super.error = error;
        }, body: body);
  }

}