From acaaca314e57228bd2b82e2bba5293c6f2c962d4 Mon Sep 17 00:00:00 2001 From: hussam al-habibeh Date: Sun, 5 Jul 2020 12:43:27 +0300 Subject: [PATCH] get clinic list after changing the language --- lib/config/config.dart | 14 ++++++++ lib/interceptor/http_interceptor.dart | 48 +++++++++++++-------------- lib/providers/auth_provider.dart | 17 +--------- lib/providers/project_provider.dart | 10 +++--- lib/screens/dashboard_screen.dart | 7 ++-- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/lib/config/config.dart b/lib/config/config.dart index 153e5d3a..1054b1d0 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -16,6 +16,8 @@ const PATIENT_REFER_TO_DOCTOR_URL = "Services/DoctorApplication.svc/REST/ReferToDoctor"; const PATIENT_GET_DOCTOR_BY_CLINIC_URL = "Services/DoctorApplication.svc/REST/GetDoctorsByClinicID"; +const GET_CLINICS_FOR_DOCTOR = + 'Services/DoctorApplication.svc/REST/GetClinicsForDoctor'; const PATIENT_GET_LIST_REFERAL_URL = "Services/Lists.svc/REST/GetList_STPReferralFrequency"; const PATIENT_GET_CLINIC_BY_PROJECT_URL = @@ -60,6 +62,18 @@ const GET_DOCTOR_WORKING_HOURS_TABLE = const GET_PATIENT_LAB_RESULTS = 'Services/DoctorApplication.svc/REST/GetPatientLabResults'; +const LOGIN_URL = 'Services/Sentry.svc/REST/MemberLogIN_New'; +const INSERT_DEVICE_IMEI = + 'Services/Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; +const SELECT_DEVICE_IMEI = + 'Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; + +const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = + 'Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; + +const MEMBER_CHECK_ACTIVATION_CODE_NEW = + 'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; +const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; var selectedPatientType = 1; diff --git a/lib/interceptor/http_interceptor.dart b/lib/interceptor/http_interceptor.dart index 4d0f9c33..7f5488b0 100644 --- a/lib/interceptor/http_interceptor.dart +++ b/lib/interceptor/http_interceptor.dart @@ -8,6 +8,7 @@ import 'package:http_interceptor/http_interceptor.dart'; import '../providers/auth_provider.dart'; import '../util/dr_app_shared_pref.dart'; +import 'package:doctor_app_flutter/config/config.dart'; DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); List publicUrls = [ @@ -18,10 +19,9 @@ List publicUrls = [ ]; class HttpInterceptor extends InterceptorContract { - - Client getClient(){ - return HttpClientWithInterceptor.build(interceptors: [this]); -} + Client getClient() { + return HttpClientWithInterceptor.build(interceptors: [this]); + } Future interceptRequest({RequestData data}) async { print('RequestData ${data.body}'); @@ -29,26 +29,26 @@ class HttpInterceptor extends InterceptorContract { try { data.headers["Content-Type"] = "application/json"; data.headers["Accept"] = "application/json"; - // if (publicUrls.contains(data.url)) { - // var loggedUserInfo = await sharedPref.getObj('loggedUser'); - // var token = await sharedPref.getString(TOKEN); - // // print("token"+token); - // // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}'); - // // // the sevices handel the token in differat name so I ask to be change - // // // we must change the imple - // var body = json.decode(data.body); - // body['LogInTokenID']=token; - // data.body = json.encode(body); - - // // data.body['LogInTokenID'] = ''; - // } else { - // if (data.body['LogInTokenID']) { - // data.body['LogInTokenID'] = ''; - // } - // if (data.body['TokenID']) { - // data.body['TokenID'] = ''; - // } - // } + // if (publicUrls.contains(data.url)) { + // var loggedUserInfo = await sharedPref.getObj('loggedUser'); + // var token = await sharedPref.getString(TOKEN); + // // print("token"+token); + // // print('loggedUserInfo${loggedUserInfo["LogInTokenID"]}'); + // // // the sevices handel the token in differat name so I ask to be change + // // // we must change the imple + // var body = json.decode(data.body); + // body['LogInTokenID']=token; + // data.body = json.encode(body); + + // // data.body['LogInTokenID'] = ''; + // } else { + // if (data.body['LogInTokenID']) { + // data.body['LogInTokenID'] = ''; + // } + // if (data.body['TokenID']) { + // data.body['TokenID'] = ''; + // } + // } } catch (e) { print(e); } diff --git a/lib/providers/auth_provider.dart b/lib/providers/auth_provider.dart index a66c6192..69551b7b 100644 --- a/lib/providers/auth_provider.dart +++ b/lib/providers/auth_provider.dart @@ -3,25 +3,10 @@ import 'package:doctor_app_flutter/models/doctor/clinic_model.dart'; import 'package:doctor_app_flutter/config/shared_pref_kay.dart'; import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart'; import 'package:flutter/cupertino.dart'; +import 'package:doctor_app_flutter/config/config.dart'; import '../models/doctor/user_model.dart'; -const LOGIN_URL = 'Services/Sentry.svc/REST/MemberLogIN_New'; -const INSERT_DEVICE_IMEI = - 'Services/Sentry.svc/REST/DoctorApplication_INSERTDeviceIMEI'; -const SELECT_DEVICE_IMEI = - 'Services/Sentry.svc/REST/DoctorApplication_SELECTDeviceIMEIbyIMEI'; - -const SEND_ACTIVATION_CODE_BY_OTP_NOTIFICATION_TYPE = - 'Services/Sentry.svc/REST/DoctorApplication_SendActivationCodebyOTPNotificationType'; - -const MEMBER_CHECK_ACTIVATION_CODE_NEW = - 'Services/Sentry.svc/REST/MemberCheckActivationCode_New'; -const GET_DOC_PROFILES = 'Services/Doctors.svc/REST/GetDocProfiles'; - -const GET_CLINICS_FOR_DOCTOR = - 'Services/DoctorApplication.svc/REST/GetClinicsForDoctor'; - DrAppSharedPreferances sharedPref = new DrAppSharedPreferances(); enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED } diff --git a/lib/providers/project_provider.dart b/lib/providers/project_provider.dart index 81f50c42..7548dc2c 100644 --- a/lib/providers/project_provider.dart +++ b/lib/providers/project_provider.dart @@ -21,7 +21,7 @@ class ProjectProvider with ChangeNotifier { String currentLanguage = 'ar'; bool _isArabic = false; bool isInternetConnection = true; - List clinicList = []; + List doctorClinicsList = []; bool isLoading = false; bool isError = false; String error = ''; @@ -78,7 +78,7 @@ class ProjectProvider with ChangeNotifier { callServicesAfterChangeLang() { getProfile(); - getClinicNames(); + getDoctorClinicsList(); } @override @@ -87,15 +87,15 @@ class ProjectProvider with ChangeNotifier { super.dispose(); } - Future getClinicNames() async { + Future getDoctorClinicsList() async { try { dynamic localRes; await BaseAppClient.post(GET_CLINICS_FOR_DOCTOR, onSuccess: (dynamic response, int statusCode) { - clinicList = []; + doctorClinicsList = []; response['List_DoctorsClinic'].forEach((v) { - clinicList.add(new ClinicModel.fromJson(v)); + doctorClinicsList.add(new ClinicModel.fromJson(v)); }); localRes = response; }, onFailure: (String error, int statusCode) { diff --git a/lib/screens/dashboard_screen.dart b/lib/screens/dashboard_screen.dart index 4a1a2f46..cab257e0 100644 --- a/lib/screens/dashboard_screen.dart +++ b/lib/screens/dashboard_screen.dart @@ -57,7 +57,7 @@ class _DashboardScreenState extends State { super.didChangeDependencies(); if (_isInit) { projectsProvider = Provider.of(context); - projectsProvider.getClinicNames(); + projectsProvider.getDoctorClinicsList(); } _isInit = false; } @@ -117,7 +117,8 @@ class _DashboardScreenState extends State { showCupertinoPicker( decKey: '', context: context, - actionList: projectsProvider.clinicList); + actionList: + projectsProvider.doctorClinicsList); }, child: Container( margin: @@ -574,7 +575,7 @@ class _DashboardScreenState extends State { onTap: () => changeClinic(e.clinicID, context), child: Text( - e.clinicName ?? 'asd', + e.clinicName, style: TextStyle( fontSize: SizeConfig.textMultiplier *