import 'package:hmg_patient_app/config/config.dart';
import 'package:hmg_patient_app/config/shared_pref_kay.dart';
import 'package:hmg_patient_app/core/model/er/projectavgerwaitingtime.dart';

import '../base_service.dart';

class ErService extends BaseService {
  List<ProjectAvgERWaitingTime> projectAvgERWaitingTimeModelList =[];

  Map<String, dynamic> body = Map();

  Future getProjectAvgERWaitingTimeOrders({int? id, int? projectID}) async {
    hasError = false;

    if (id != null && projectID != null) {
      body['ID'] = id;
      body['ProjectID'] = projectID;
    }
    var lat = await sharedPref.getDouble(USER_LAT);
    var long = await sharedPref.getDouble(USER_LONG);
    body['Latitude'] = lat ?? 0;
    body['Longitude'] = long ?? 0;
    body['IsForER'] = true;

    dynamic localRes;

    await baseAppClient.post(GET_NEAREST_HOSPITAL,
        onSuccess: (dynamic response, int statusCode) {
          localRes = response;
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: body);
    return Future.value(localRes);
  }
}
