import 'package:doctor_app_flutter/client/base_app_client.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';

class BaseService {
  String error;
  bool hasError = false;
  BaseAppClient baseAppClient = BaseAppClient();
  DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
  DoctorProfileModel doctorProfile;

  List<PatiantInformtion> patientArrivalList = [];

  BaseService(){
    doctorProfile = null;
  }

  //TODO add the user login model when we need it
  Future<DoctorProfileModel> getDoctorProfile({bool isGetProfile = false}) async {
    if(isGetProfile)
    {
      Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
      if (profile != null) {
        doctorProfile = DoctorProfileModel.fromJson(profile);
        if (doctorProfile != null) {
          return doctorProfile;
        }
      }
    }
    if (doctorProfile == null) {
      Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
      if (profile != null) {
        doctorProfile = DoctorProfileModel.fromJson(profile);
        if (doctorProfile != null) {
          return doctorProfile;
        }
      }
      return null;
    } else {
      return doctorProfile;
    }
  }


}
