From c48f393f95ac7dd574487005a4f3cd8fb6bd3c56 Mon Sep 17 00:00:00 2001 From: Sultan khan <> Date: Tue, 9 May 2023 10:33:49 +0300 Subject: [PATCH] Dubai registration fixed --- lib/config/config.dart | 6 +- lib/config/shared_pref_kay.dart | 1 + lib/core/viewModels/project_view_model.dart | 8 +- .../check_paitent_authentication_req.dart | 16 +- lib/models/Authentication/countries_list.dart | 21 + lib/pages/login/confirm-login.dart | 19 +- lib/pages/login/register-info.dart | 1095 ++++++++++++----- lib/pages/login/register.dart | 9 +- .../authentication/auth_provider.dart | 14 +- .../clinic_services/get_clinic_service.dart | 10 + 10 files changed, 882 insertions(+), 317 deletions(-) create mode 100644 lib/models/Authentication/countries_list.dart diff --git a/lib/config/config.dart b/lib/config/config.dart index 9b5b512e..96c71d2c 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -19,9 +19,9 @@ var PACKAGES_SHOPPING_CART = '/api/shopping_cart_items'; var PACKAGES_ORDERS = '/api/orders'; var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; -// var BASE_URL = 'http://10.50.100.198:3334/'; + // var BASE_URL = 'http://10.50.100.198:2018/'; var BASE_URL = 'https://uat.hmgwebservices.com/'; -// var BASE_URL = 'https://hmgwebservices.com/'; +//var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; @@ -591,6 +591,8 @@ var CANCEL_PHARMA_LIVECARE_REQUEST = 'https://vcallapi.hmg.com/api/PharmaLiveCar var INSERT_FREE_SLOTS_LOGS = 'Services/Doctors.svc/Rest/InsertDoctorFreeSlotsLogs'; +var GET_NATIONALITY ='Services/Lists.svc/REST/GetNationality'; + class AppGlobal { static var context; diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index 9e5c4f27..ec82db11 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -42,3 +42,4 @@ const APPOINTMENT_HISTORY_MEDICAL = 'APPOINTMENT_HISTORY_MEDICAL'; const CLINICS_LIST = 'CLINICS_LIST'; const COVID_QA_LIST = 'COVID_QA_LIST'; const IS_COVID_CONSENT_SHOWN = 'IS_COVID_CONSENT_SHOWN'; +const REGISTER_INFO_DUBAI ='register-info-dubai'; diff --git a/lib/core/viewModels/project_view_model.dart b/lib/core/viewModels/project_view_model.dart index a536d527..c45e7dd8 100644 --- a/lib/core/viewModels/project_view_model.dart +++ b/lib/core/viewModels/project_view_model.dart @@ -8,6 +8,7 @@ import 'package:diplomaticquarterapp/core/model/privilege/PrivilegeModel.dart'; import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/laser_body_parts.dart'; +import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart'; import 'package:diplomaticquarterapp/uitl/PlatformBridge.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:flutter/cupertino.dart'; @@ -38,9 +39,10 @@ class ProjectViewModel extends BaseViewModel { double _latitude; double _longitude; + RegisterInfoResponse _registerInfo =RegisterInfoResponse(); double get latitude => _latitude; double get longitude => _longitude; - + RegisterInfoResponse get registerInfo=> _registerInfo; dynamic get searchValue => searchvalue; Locale get appLocal => _appLocale; @@ -164,4 +166,8 @@ class ProjectViewModel extends BaseViewModel { searchvalue = data; notifyListeners(); } + setRegisterData(RegisterInfoResponse data){ + _registerInfo =data; + notifyListeners(); + } } diff --git a/lib/models/Authentication/check_paitent_authentication_req.dart b/lib/models/Authentication/check_paitent_authentication_req.dart index 2846c1fc..76493f87 100644 --- a/lib/models/Authentication/check_paitent_authentication_req.dart +++ b/lib/models/Authentication/check_paitent_authentication_req.dart @@ -15,7 +15,9 @@ class CheckPatientAuthenticationReq { Null sessionID; bool isDentalAllowedBackend; int deviceTypeID; - + String dob; + int isHijri; + String healthId; CheckPatientAuthenticationReq( {this.patientMobileNumber, this.zipCode, @@ -32,7 +34,11 @@ class CheckPatientAuthenticationReq { this.patientOutSA, this.sessionID, this.isDentalAllowedBackend, - this.deviceTypeID}); + this.deviceTypeID, + this.dob, + this.isHijri, + this.healthId + }); CheckPatientAuthenticationReq.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; @@ -51,6 +57,9 @@ class CheckPatientAuthenticationReq { sessionID = json['SessionID']; isDentalAllowedBackend = json['isDentalAllowedBackend']; deviceTypeID = json['DeviceTypeID']; + dob = json['dob']; + isHijri = json['isHijri']; + healthId = json['HealthId']; } Map toJson() { @@ -71,6 +80,9 @@ class CheckPatientAuthenticationReq { data['SessionID'] = this.sessionID; data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['DeviceTypeID'] = this.deviceTypeID; + data['dob'] =this.dob; + data['isHijri'] = this.isHijri; + data['HealthId'] = healthId; return data; } } diff --git a/lib/models/Authentication/countries_list.dart b/lib/models/Authentication/countries_list.dart new file mode 100644 index 00000000..3c314da9 --- /dev/null +++ b/lib/models/Authentication/countries_list.dart @@ -0,0 +1,21 @@ +class CountriesLists { + String iD; + String name; + dynamic nameN; + + CountriesLists({this.iD, this.name, this.nameN}); + + CountriesLists.fromJson(Map json) { + iD = json['ID']; + name = json['Name']; + nameN = json['NameN']; + } + + Map toJson() { + final Map data = new Map(); + data['ID'] = this.iD; + data['Name'] = this.name; + data['NameN'] = this.nameN; + return data; + } +} \ No newline at end of file diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 1fd3bbda..73012bd5 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -42,8 +42,8 @@ import 'package:provider/provider.dart'; class ConfirmLogin extends StatefulWidget { final Function changePageViewIndex; final fromRegistration; - - const ConfirmLogin({Key key, this.changePageViewIndex, this.fromRegistration = false}) : super(key: key); + final bool isDubai; + const ConfirmLogin({Key key, this.changePageViewIndex, this.fromRegistration = false, this.isDubai =false}) : super(key: key); @override _ConfirmLogin createState() => _ConfirmLogin(); @@ -385,8 +385,10 @@ class _ConfirmLogin extends State { var request = this.getCommonRequest(type: type); request.sMSSignature = await SMSOTP.getSignature(); GifLoaderDialogUtils.showMyDialog(context); - if (healthId != null) { - request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); + if (healthId != null || widget.isDubai) { + if(!widget.isDubai){ + request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob)); + } request.healthId = healthId; request.isHijri = isHijri; await this.authService.sendActivationCodeRegister(request).then((result) { @@ -547,7 +549,7 @@ class _ConfirmLogin extends State { request.searchType = this.registerd_data.searchType != null ? this.registerd_data.searchType : 1; request.patientID = this.registerd_data.patientID != null ? this.registerd_data.patientID : 0; request.patientIdentificationID = request.nationalID = this.registerd_data.patientIdentificationID != null ? this.registerd_data.patientIdentificationID : '0'; - + request.dob = this.registerd_data.dob; request.isRegister = this.registerd_data.isRegister; } else { request.searchType = request.searchType != null ? request.searchType : 2; @@ -565,8 +567,10 @@ class _ConfirmLogin extends State { GifLoaderDialogUtils.showMyDialog(context); var request = this.getCommonRequest().toJson(); dynamic res; - if (healthId != null) { - request['DOB'] = dob; + if (healthId != null || widget.isDubai) { + if(!widget.isDubai) { + request['DOB'] = dob; + } request['HealthId'] = healthId; request['IsHijri'] = isHijri; @@ -579,6 +583,7 @@ class _ConfirmLogin extends State { result = CheckActivationCode.fromJson(result), if (this.registerd_data != null && this.registerd_data.isRegister == true) { + // if(widget.isDubai ==false){ widget.changePageViewIndex(1), Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)), } diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index 5d7db69f..716c2006 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -6,8 +6,10 @@ import 'package:diplomaticquarterapp/core/viewModels/appointment_rate_view_model import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart'; import 'package:diplomaticquarterapp/locator.dart'; import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart'; -import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart' as checkActivation; +import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart' + as checkActivation; import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; +import 'package:diplomaticquarterapp/models/Authentication/countries_list.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart'; import 'package:diplomaticquarterapp/pages/landing/landing_page.dart'; import 'package:diplomaticquarterapp/pages/rateAppointment/rate_appointment_doctor.dart'; @@ -36,7 +38,8 @@ class RegisterInfo extends StatefulWidget { final Function changePageViewIndex; final int page; - const RegisterInfo({Key key, this.changePageViewIndex, this.page = 1}) : super(key: key); + const RegisterInfo({Key key, this.changePageViewIndex, this.page = 1}) + : super(key: key); @override _RegisterInfo createState() => _RegisterInfo(); @@ -45,7 +48,7 @@ class RegisterInfo extends StatefulWidget { class _RegisterInfo extends State { final authService = new AuthProvider(); final sharedPref = new AppSharedPreferences(); - RegisterInfoResponse registerInfo; + RegisterInfoResponse registerInfo =RegisterInfoResponse(); bool isLoading; int page; final List locationList = [ @@ -53,31 +56,49 @@ class _RegisterInfo extends State { new Location(name: 'Dubai', value: '2'), ]; String language = '1'; - var registerd_data; + CheckPatientAuthenticationReq registerd_data; final List languageList = [ new Language(name: 'English', value: '2'), new Language(name: 'Arabic', value: '1'), ]; + final List genderList = [ + new Language(name: 'Male', value: 'M'), + new Language(name: 'Female', value: 'F'), + ]; + final List maritalList = [ + new Language(name: 'Married', value: 'M'), + new Language(name: 'Single', value: 'S'), + new Language(name: 'Divorce', value: 'D'), + ]; String email = ''; - + List countriesList = []; ToDoCountProviderModel toDoProvider; String location = '1'; - AuthenticatedUserObject authenticatedUserObject = locator(); + AuthenticatedUserObject authenticatedUserObject = + locator(); ProjectViewModel projectViewModel; - AppointmentRateViewModel appointmentRateViewModel = locator(); + AppointmentRateViewModel appointmentRateViewModel = + locator(); + bool isDubai =false; + RegisterInfoResponse data = RegisterInfoResponse(); + CheckPatientAuthenticationReq data2; + String gender = 'M'; + String maritalStatus = 'M'; + String nationality = 'SAU'; @override void initState() { - WidgetsBinding.instance.addPostFrameCallback((timeStamp) { - getRegisterInfo(); - }); - setState(() { - page = widget.page; - }); - super.initState(); + if(widget.page ==1) { + getCountries(); + } + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + getRegisterInfo(); + }); + page = widget.page; + super.initState(); } @override @@ -85,17 +106,23 @@ class _RegisterInfo extends State { projectViewModel = Provider.of(context); toDoProvider = Provider.of(context); return AppScaffold( - appBarTitle: TranslationBase.of(context).register, + appBarTitle: TranslationBase + .of(context) + .register, isShowAppBar: false, isShowDecPage: false, body: SingleChildScrollView( padding: EdgeInsets.all(30), - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ + child: + Column(crossAxisAlignment: CrossAxisAlignment.start, children: < + Widget>[ Row( children: [ Expanded( child: AppText( - TranslationBase.of(context).personalInfo, + TranslationBase + .of(context) + .personalInfo, fontSize: 16, textAlign: TextAlign.left, fontWeight: FontWeight.bold, @@ -105,169 +132,385 @@ class _RegisterInfo extends State { ], ), SizedBox(height: 20), - registerInfo != null && page == 1 + (isDubai && page == 1) + ? Column( + children: [ + SizedBox(height: 20), + getnameField( + TranslationBase + .of(context) + .identificationNumber, + registerd_data.patientIdentificationID, + TranslationBase + .of(context) + .mobileNumber, + registerd_data.patientMobileNumber.toString()), + // SizedBox(height: 20), + getnameField( + '', + + + inputWidget( TranslationBase + .of(context) + .firstName, TranslationBase + .of(context) + .firstName,'fName'), + '', + inputWidget( TranslationBase + .of(context) + .middleName, TranslationBase + .of(context) + .middleName,'sName'), + ), + + getnameField( + '', + inputWidget( TranslationBase + .of(context) + .lastName, TranslationBase + .of(context) + .lastName, 'lName'), + + TranslationBase + .of(context) + .gender, + Container( + height: 20, + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: gender, + hint: Text(TranslationBase + .of(context) + .gender), + iconSize: 40, + elevation: 16, + onChanged: (value) => + { + setState(() { + gender = value; + registerInfo.gender = value; + }) + }, + items: genderList + .map>( + (Language value) { + return DropdownMenuItem( + value: value.value, + child: Text(value.name), + ); + }).toList()))), + ), + SizedBox(height: 20), + getnameField( + TranslationBase + .of(context) + .maritalStatus, + Container( + height: 18, + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: maritalStatus, + hint: Text(TranslationBase + .of(context) + .maritalStatus), + iconSize: 40, + elevation: 16, + onChanged: (value) => + { + setState(() { + maritalStatus = value; + registerInfo.maritalStatusCode = value; + }) + }, + items: maritalList + .map>( + (Language value) { + return DropdownMenuItem( + value: value.value, + child: Text(value.name), + ); + }).toList()))), + TranslationBase + .of(context) + .nationality, + Container( + height: 22, + child: DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: nationality, + hint: Text(TranslationBase + .of(context) + .nationality), + iconSize: 40, + elevation: 16, + onChanged: (value) => + { + setState(() { + nationality = value; + registerInfo.nationalityCode = value; + }) + }, + items: countriesList + .map>( + (CountriesLists value) { + return DropdownMenuItem( + value: value.iD, + child: Text(value.name), + ); + }).toList())))), + SizedBox(height: 20), + getnameField( + TranslationBase + .of(context) + .dateOfBirth, + registerd_data.dob, + "", ""), + SizedBox(height: 20), + ], + ) + : (registerInfo.healthId != null && page == 1) + ? Column( + children: [ + SizedBox(height: 20), + getnameField( + TranslationBase + .of(context) + .identificationNumber, + registerInfo.idNumber, + TranslationBase + .of(context) + .firstName, + registerInfo.firstNameEn == '-' + ? registerInfo.firstNameAr + : registerInfo.firstNameEn), + SizedBox(height: 20), + getnameField( + TranslationBase + .of(context) + .middleName, + registerInfo.secondNameEn == '-' + ? registerInfo.secondNameEn + : registerInfo.secondNameEn, + TranslationBase + .of(context) + .lastName, + registerInfo.lastNameEn == '-' + ? registerInfo.lastNameEn + : registerInfo.lastNameEn), + SizedBox(height: 20), + getnameField( + TranslationBase + .of(context) + .gender, + registerInfo.maritalStatusCode == 'U' + ? 'Unknown' + : registerInfo.maritalStatusCode == 'M' + ? 'Male' + : 'Female', + TranslationBase + .of(context) + .maritalStatus, + registerInfo.maritalStatus), + SizedBox(height: 20), + getnameField( + TranslationBase + .of(context) + .nationality, + registerInfo.nationality, + TranslationBase + .of(context) + .mobileNumber, + registerd_data.patientMobileNumber.toString()), + SizedBox(height: 20), + getnameField(TranslationBase + .of(context) + .dateOfBirth, + registerInfo.dateOfBirth, "", ""), + SizedBox(height: 20), + ], + ) + : widget.page == 2 ? Column( - children: [ - SizedBox(height: 20), - getnameField(TranslationBase.of(context).identificationNumber, registerInfo.idNumber, TranslationBase.of(context).firstName, - registerInfo.firstNameEn == '-' ? registerInfo.firstNameAr : registerInfo.firstNameEn), - SizedBox(height: 20), - getnameField(TranslationBase.of(context).middleName, registerInfo.secondNameEn == '-' ? registerInfo.secondNameEn : registerInfo.secondNameEn, - TranslationBase.of(context).lastName, registerInfo.lastNameEn == '-' ? registerInfo.lastNameEn : registerInfo.lastNameEn), - SizedBox(height: 20), - getnameField( - TranslationBase.of(context).gender, - registerInfo.maritalStatusCode == 'U' - ? 'Unknown' - : registerInfo.maritalStatusCode == 'M' - ? 'Male' - : 'Female', - TranslationBase.of(context).maritalStatus, - registerInfo.maritalStatus), - SizedBox(height: 20), - getnameField(TranslationBase.of(context).nationality, registerInfo.nationality, TranslationBase.of(context).mobileNumber, registerd_data.patientMobileNumber.toString()), - SizedBox(height: 20), - getnameField(TranslationBase.of(context).dateOfBirth, registerInfo.dateOfBirth, "", ""), - SizedBox(height: 20), - ], - ) - : registerInfo != null && widget.page == 2 - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - width: double.infinity, - decoration: containerRadius(Colors.white, 12), - padding: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 25), - child: Row(children: [ - Flexible( - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - TranslationBase.of(context).prefferedLanguage, - style: TextStyle( - fontSize: 11, - letterSpacing: -0.44, - fontWeight: FontWeight.w600, - ), + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: double.infinity, + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.only( + left: 10, right: 10, top: 5, bottom: 25), + child: Row(children: [ + Flexible( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + TranslationBase + .of(context) + .prefferedLanguage, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, ), - Container( - height: 18, - child: DropdownButtonHideUnderline( - child: DropdownButton( - isExpanded: true, - value: language, - hint: Text(TranslationBase.of(context).prefferedLanguage), - iconSize: 40, - elevation: 16, - onChanged: (value) => { - setState(() { - language = value; - }) - }, - items: languageList.map>((Language value) { - return DropdownMenuItem( - value: value.value, - child: Text(value.name), - ); - }).toList()))) - ])) - ])), - SizedBox( - height: 20, - ), - Container( - width: double.infinity, - decoration: containerRadius(Colors.white, 12), - padding: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 25), - child: Row(children: [ - Flexible( - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - TranslationBase.of(context).selectLocation, - style: TextStyle( - fontSize: 11, - letterSpacing: -0.44, - fontWeight: FontWeight.w600, - ), + ), + Container( + height: 18, + child: + DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: language, + hint: Text(TranslationBase + .of(context) + .prefferedLanguage), + iconSize: 40, + elevation: 16, + onChanged: (value) => + { + setState(() { + language = + value; + }) + }, + items: languageList.map< + DropdownMenuItem< + String>>( + (Language value) { + return DropdownMenuItem< + String>( + value: + value.value, + child: Text( + value.name), + ); + }).toList()))) + ])) + ])), + SizedBox( + height: 20, + ), + Container( + width: double.infinity, + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.only( + left: 10, right: 10, top: 5, bottom: 25), + child: Row(children: [ + Flexible( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + TranslationBase + .of(context) + .selectLocation, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, ), - Container( - height: 18, - child: DropdownButtonHideUnderline( - child: DropdownButton( - isExpanded: true, - value: location, - hint: Text(TranslationBase.of(context).selectLocation), - iconSize: 40, - elevation: 16, - onChanged: (value) => { - setState(() { - location = value; - }) - }, - items: locationList.map>((Location value) { - return DropdownMenuItem( - value: value.value, - child: Text( - value.name, - ), - ); - }).toList()))) - ])) - ])), - SizedBox( - height: 20, - ), - Container( - width: double.infinity, - decoration: containerRadius(Colors.white, 12), - padding: EdgeInsets.only(left: 10, right: 10, top: 5, bottom: 12), - margin: EdgeInsets.only(bottom: 0), - child: Row(children: [ - Flexible( - child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - TranslationBase.of(context).email, - style: TextStyle( - fontSize: 11, - letterSpacing: -0.44, - fontWeight: FontWeight.w600, - ), + ), + Container( + height: 18, + child: + DropdownButtonHideUnderline( + child: DropdownButton( + isExpanded: true, + value: location, + hint: Text( + TranslationBase + .of( + context) + .selectLocation), + iconSize: 40, + elevation: 16, + onChanged: (value) => + { + setState(() { + location = + value; + }) + }, + items: locationList.map< + DropdownMenuItem< + String>>( + (Location value) { + return DropdownMenuItem< + String>( + value: + value.value, + child: Text( + value.name, + ), + ); + }).toList()))) + ])) + ])), + SizedBox( + height: 20, + ), + Container( + width: double.infinity, + decoration: containerRadius(Colors.white, 12), + padding: EdgeInsets.only( + left: 10, right: 10, top: 5, bottom: 12), + margin: EdgeInsets.only(bottom: 0), + child: Row(children: [ + Flexible( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + TranslationBase + .of(context) + .email, + style: TextStyle( + fontSize: 11, + letterSpacing: -0.44, + fontWeight: FontWeight.w600, ), - Container( - child: TextField( - onChanged: (value) { - setState(() { - email = value; - }); - }, - style: TextStyle( - fontSize: 14, - height: 21 / 14, - fontWeight: FontWeight.w400, - color: Color(0xff2B353E), - letterSpacing: -0.44, - ), - decoration: InputDecoration( - isDense: true, - hintStyle: TextStyle( + ), + Container( + child: TextField( + onChanged: (value) { + setState(() { + email = value; + }); + }, + style: TextStyle( fontSize: 14, height: 21 / 14, fontWeight: FontWeight.w400, - color: Color(0xff575757), - letterSpacing: -0.56, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: + BoxConstraints(minWidth: 50), + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, ), - prefixIconConstraints: BoxConstraints(minWidth: 50), - contentPadding: EdgeInsets.zero, - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - ), - )) - ])) - ])), - ], - ) - : SizedBox(), + )) + ])) + ])), + ], + ) + : SizedBox(), ]), ), bottomSheet: Container( @@ -278,89 +521,148 @@ class _RegisterInfo extends State { Expanded( child: Padding( padding: EdgeInsets.all(10), - child: DefaultButton(TranslationBase.of(context).cancel, () { + child: + DefaultButton(TranslationBase + .of(context) + .cancel, () { Navigator.of(context).pop(); - locator().loginRegistration.registration_cancel(step: page == 1 ? 'personal info' : 'other details'); + locator() + .loginRegistration + .registration_cancel( + step: page == 1 + ? 'personal info' + : 'other details'); }, textColor: Colors.white, color: Color(0xffD02127))), ), Expanded( child: Padding( padding: EdgeInsets.all(10), - child: DefaultButton(page == 1 ? TranslationBase.of(context).next : TranslationBase.of(context).register, () { + child: DefaultButton( + page == 1 + ? TranslationBase + .of(context) + .next + : TranslationBase + .of(context) + .register, () { nextPage(); - page == 1 ? locator().loginRegistration.registration_personal_info() : locator().loginRegistration.registration_patient_info(); - }, textColor: Colors.white, color: isValid() == true && page == 2 || page == 1 ? Color(0xff359846) : Colors.grey)), + page == 1 + ? locator() + .loginRegistration + .registration_personal_info() + : locator() + .loginRegistration + .registration_patient_info(); + }, + textColor: Colors.white, + color: isValid() == true + ? Color(0xff359846) + : Colors.grey)), ), ], ))); } - nextPage() { + nextPage() async{ if (page == 1) { - setState(() { + if(isDubai) { + await setRegisterData(); widget.changePageViewIndex(2); - }); + } + else{ + widget.changePageViewIndex(2); + } } else { registerNow(); } } + setRegisterData() async{ + registerInfo.gender = gender; + registerInfo.maritalStatusCode =maritalStatus; + registerInfo.nationalityCode =nationality; + projectViewModel.setRegisterData(registerInfo); + // await sharedPref.setObject(REGISTER_INFO_DUBAI, registerInfo); + } registerNow() { - dynamic request = getTempUserRequest(); - GifLoaderDialogUtils.showMyDialog(context); + dynamic request; + if(isDubai) + request = getTempUserRequestDubai(); + else + request = getTempUserRequest(); + + GifLoaderDialogUtils.showMyDialog(context); dynamic res; this .authService .registerUser(request) - .then((result) => { - GifLoaderDialogUtils.hideDialog(context), - if (result is String) - { - new ConfirmDialog( - context: context, - confirmMessage: result, - okText: TranslationBase.of(context).ok, - cancelText: TranslationBase.of(context).cancel_nocaps, - okFunction: () => {ConfirmDialog.closeAlertDialog(context)}, - cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}).showAlertDialog(context) - } - else - { - res = result, - result = checkActivation.CheckActivationCode.fromJson(result), - // result.list.isFamily = false, - // sharedPref.setObject(USER_PROFILE, result.list), - // this.sharedPref.setObject(MAIN_USER, result.list), - // sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), - // sharedPref.setString(TOKEN, result.authenticationTokenID), - // this.setUser(result), - sharedPref.remove(FAMILY_FILE), - result.list.isFamily = false, - - sharedPref.setString(BLOOD_TYPE, result.patientBloodType), - authenticatedUserObject.user = result.list, - projectViewModel.setPrivilege(privilegeList: res), - sharedPref.setObject(MAIN_USER, result.list), - sharedPref.setObject(USER_PROFILE, result.list), - - sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), - sharedPref.setString(TOKEN, result.authenticationTokenID), - AppToast.showSuccessToast(message: TranslationBase.of(context).successRegister), - checkIfUserAgreedBefore(result), - projectViewModel.analytics.loginRegistration.registration_confirmation() - } - }) + .then((result) => + { + GifLoaderDialogUtils.hideDialog(context), + if (result is String) + { + new ConfirmDialog( + context: context, + confirmMessage: result, + okText: TranslationBase + .of(context) + .ok, + cancelText: TranslationBase + .of(context) + .cancel_nocaps, + okFunction: () => + {ConfirmDialog.closeAlertDialog(context)}, + cancelFunction: () => + { + ConfirmDialog.closeAlertDialog(context) + }).showAlertDialog(context) + } + else + { + res = result, + result = checkActivation.CheckActivationCode.fromJson(result), + // result.list.isFamily = false, + // sharedPref.setObject(USER_PROFILE, result.list), + // this.sharedPref.setObject(MAIN_USER, result.list), + // sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), + // sharedPref.setString(TOKEN, result.authenticationTokenID), + // this.setUser(result), + sharedPref.remove(FAMILY_FILE), + result.list.isFamily = false, + + sharedPref.setString(BLOOD_TYPE, result.patientBloodType), + authenticatedUserObject.user = result.list, + projectViewModel.setPrivilege(privilegeList: res), + sharedPref.setObject(MAIN_USER, result.list), + sharedPref.setObject(USER_PROFILE, result.list), + + sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), + sharedPref.setString(TOKEN, result.authenticationTokenID), + AppToast.showSuccessToast( + message: TranslationBase + .of(context) + .successRegister), + checkIfUserAgreedBefore(result), + projectViewModel.analytics.loginRegistration + .registration_confirmation() + } + }) .catchError((err) { // GifLoaderDialogUtils.hideDialog(context); ConfirmDialog dialog = new ConfirmDialog( context: context, confirmMessage: err, - okText: TranslationBase.of(context).confirm, - cancelText: TranslationBase.of(context).cancel_nocaps, + okText: TranslationBase + .of(context) + .confirm, + cancelText: TranslationBase + .of(context) + .cancel_nocaps, okFunction: () => {ConfirmDialog.closeAlertDialog(context)}, cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)}); dialog.showAlertDialog(context); - projectViewModel.analytics.loginRegistration.registration_fail(errorType: err); + projectViewModel.analytics.loginRegistration + .registration_fail(errorType: err); }); } @@ -374,30 +676,44 @@ class _RegisterInfo extends State { } getRegisterInfo() async { - var data = RegisterInfoResponse.fromJson(await sharedPref.getObject(NHIC_DATA)); + + if (await sharedPref.getObject(NHIC_DATA) != null) { + data = + RegisterInfoResponse.fromJson(await sharedPref.getObject(NHIC_DATA)); + this.registerInfo = data; + } if (await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN) != null) { - var data2 = CheckPatientAuthenticationReq.fromJson(await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); + data2 = CheckPatientAuthenticationReq.fromJson( + await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); setState(() { - this.registerInfo = data; + this.registerd_data = data2; + isDubai = data2.patientOutSA == 1 ? true : false; }); } } getTempUserRequest() { + + DateFormat dateFormat = DateFormat("mm/dd/yyyy"); print(dateFormat.parse(registerInfo.dateOfBirth)); - var hDate = new HijriCalendar.fromDate(dateFormat.parse(registerInfo.dateOfBirth)); + var hDate = + new HijriCalendar.fromDate(dateFormat.parse(registerInfo.dateOfBirth)); var date = hDate.toString(); return { "Patientobject": { "TempValue": true, - "PatientIdentificationType": registerInfo.idNumber.substring(0, 1) == "1" ? 1 : 2, + "PatientIdentificationType": + registerInfo.idNumber.substring(0, 1) == "1" ? 1 : 2, "PatientIdentificationNo": registerInfo.idNumber, "MobileNumber": registerd_data.patientMobileNumber, - "PatientOutSA": (registerd_data.zipCode == '966' || registerd_data.zipCode == '+966') ? 0 : 1, + "PatientOutSA": (registerd_data.zipCode == '966' || + registerd_data.zipCode == '+966') + ? 0 + : 1, "FirstNameN": registerInfo.firstNameAr, "FirstName": registerInfo.firstNameEn, "MiddleNameN": registerInfo.secondNameAr, @@ -405,8 +721,9 @@ class _RegisterInfo extends State { "LastNameN": registerInfo.lastNameAr, "LastName": registerInfo.lastNameEn, "StrDateofBirth": registerInfo.dateOfBirth, - "DateofBirth": DateUtil.convertISODateToJsonDate(registerInfo.dateOfBirth.replaceAll('/', '-')), - "Gender": registerInfo.gender == 'M' ? 1 : 2, + "DateofBirth": DateUtil.convertISODateToJsonDate( + registerInfo.dateOfBirth.replaceAll('/', '-')), + "Gender": registerInfo.gender== 'M' ? 1 : 2, "NationalityID": registerInfo.nationalityCode, "eHealthIDField": registerInfo.healthId, "DateofBirthN": date, @@ -416,16 +733,76 @@ class _RegisterInfo extends State { "Marital": registerInfo.maritalStatusCode == 'U' ? '0' : registerInfo.maritalStatusCode == 'M' - ? '1' - : '2', + ? '1' + : '2', }, "PatientIdentificationID": registerInfo.idNumber, - "PatientMobileNumber": registerd_data.patientMobileNumber.toString()[0] == '0' ? registerd_data.patientMobileNumber : '0' + registerd_data.patientMobileNumber.toString(), + "PatientMobileNumber": + registerd_data.patientMobileNumber.toString()[0] == '0' + ? registerd_data.patientMobileNumber + : '0' + registerd_data.patientMobileNumber.toString(), + }; + } + + + getTempUserRequestDubai(){ + DateFormat dateFormat = DateFormat("mm/dd/yyyy"); + registerInfo= projectViewModel.registerInfo; + print(dateFormat.parse(registerd_data.dob)); + var hDate = + new HijriCalendar.fromDate(dateFormat.parse(registerd_data.dob)); + var date = hDate.toString(); + final DateFormat dateFormat1 = DateFormat('MM/dd/yyyy'); + final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); + + return { + "Patientobject": { + "TempValue": true, + "PatientIdentificationType": + registerd_data.patientIdentificationID.substring(0, 1) == "1" ? 1 : 2, + "PatientIdentificationNo": registerd_data.patientIdentificationID, + "MobileNumber": registerd_data.patientMobileNumber, + "PatientOutSA": (registerd_data.zipCode == '966' || + registerd_data.zipCode == '+966') + ? 0 + : 1, + "FirstNameN": registerInfo.firstNameAr ??"", + "FirstName": registerInfo.firstNameEn??"", + "MiddleNameN": registerInfo.secondNameAr?? "", + "MiddleName": registerInfo.secondNameEn ??"", + "LastNameN": registerInfo.lastNameAr ??"", + "LastName":registerInfo.lastNameEn ??"", + "StrDateofBirth": dateFormat1.format( + dateFormat2.parse(registerd_data.dob)), + "DateofBirth": DateUtil.convertISODateToJsonDate( + registerd_data.dob.replaceAll('/', '-')), + "Gender": registerInfo.gender== 'M' ? 1 : 2, + "NationalityID": registerInfo.nationalityCode, + "eHealthIDField":null, + "DateofBirthN": date, + "EmailAddress": email, + "SourceType": location, + "PreferredLanguage": registerd_data.languageID.toString(), + "Marital": registerInfo.maritalStatusCode == 'U' + ? '0' + : registerInfo.maritalStatusCode == 'M' + ? '1' + : '2', + }, + "PatientIdentificationID": registerd_data.patientIdentificationID, + "PatientMobileNumber": + registerd_data.patientMobileNumber.toString()[0] == '0' + ? registerd_data.patientMobileNumber + : '0' + registerd_data.patientMobileNumber.toString(), + "DOB":registerd_data.dob, + "IsHijri":registerd_data.isHijri }; } bool isValid() { - if (location != null && language != null && Utils.validEmail(email) == true) { + if ((location != null && + language != null && + Utils.validEmail(email) == true) || (registerInfo.firstNameEn !=null && registerInfo.secondNameEn !=null && registerInfo.lastNameEn !=null)) { return true; } else { return false; @@ -436,49 +813,57 @@ class _RegisterInfo extends State { return Row( children: [ Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - name1, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - letterSpacing: -0.44, - ), - ), - Text( - value1, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - letterSpacing: -0.44, - ), - ), - ], - )), + child: Padding( + padding: EdgeInsets.only(left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + name1, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + letterSpacing: -0.44, + ), + ), + value1 is String + ? Text( + value1, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.44, + ), + ) + : value1, + ], + ))), Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - name2, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - letterSpacing: -0.44, - ), - ), - Text( - value2, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.w600, - letterSpacing: -0.44, - ), - ), - ], - )) + child: Padding( + padding: EdgeInsets.only(left: 5, right: 5), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + name2, + style: TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + letterSpacing: -0.44, + ), + ), + value2 is String + ? Text( + value2, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.w600, + letterSpacing: -0.44, + ), + ) + : value2, + ], + ))) ], ); } @@ -494,7 +879,10 @@ class _RegisterInfo extends State { insertIMEI() async { var selectedOption = await sharedPref.getInt(LAST_LOGIN); - authService.insertDeviceImei(selectedOption).then((value) => {goToHome()}).catchError((err) { + authService + .insertDeviceImei(selectedOption) + .then((value) => {goToHome()}) + .catchError((err) { print(err); }); } @@ -507,28 +895,29 @@ class _RegisterInfo extends State { await authenticatedUserObject.getUser(getUser: true); appointmentRateViewModel .getIsLastAppointmentRatedList() - .then((value) => { - getToDoCount(), - GifLoaderDialogUtils.hideDialog(AppGlobal.context), - if (appointmentRateViewModel.isHaveAppointmentNotRate) - { - Navigator.pushAndRemoveUntil( - context, - FadePage( - page: RateAppointmentDoctor(), - ), - (r) => false) - } - else - { - Navigator.pushAndRemoveUntil( - context, - FadePage( - page: LandingPage(), - ), - (r) => false) - } - }) + .then((value) => + { + getToDoCount(), + GifLoaderDialogUtils.hideDialog(AppGlobal.context), + if (appointmentRateViewModel.isHaveAppointmentNotRate) + { + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: RateAppointmentDoctor(), + ), + (r) => false) + } + else + { + Navigator.pushAndRemoveUntil( + context, + FadePage( + page: LandingPage(), + ), + (r) => false) + } + }) .catchError((err) { print(err); //GifLoaderDialogUtils.hideDialog(context); @@ -547,8 +936,114 @@ class _RegisterInfo extends State { print(err); }); } + + getCountries() { + ClinicListService service = new ClinicListService(); + service.getCountries().then((res) { + if (res['MessageStatus'] == 1) { + + res['ListNationality'].forEach((items) => { + countriesList.add(CountriesLists.fromJson(items)) + }); + + setState(() {}); + } + }).catchError((err) { + print(err); + }); + } + + + Widget inputWidget(String _labelText, String _hintText, String name, {String prefix, bool isEnable = true, bool hasSelection = false}) { + return Container( + padding: EdgeInsets.only(left: 10, right: 10, bottom: 5, top: 5), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(15), + color: Colors.white, + border: Border.all( + color: Color(0xffefefef), + width: 1, + ), + ), + child: InkWell( + onTap: hasSelection ? () {} : null, + child: Row( + children: [ + Expanded( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _labelText, + style: TextStyle( + fontSize: 11, + fontWeight: FontWeight.w600, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + ), + TextField( + enabled: isEnable, + scrollPadding: EdgeInsets.zero, + keyboardType: TextInputType.number, + // controller: _controller, + onChanged: (value) => { + setState((){ + switch(name) { + case 'fName': + registerInfo.firstNameEn = registerInfo.firstNameAr = value; + break; + case 'sName': + registerInfo.secondNameEn = registerInfo.secondNameAr = value; + break; + case 'lName': + registerInfo.lastNameEn = registerInfo.lastNameAr = value; + break; + } + }) + //_controller.text =value + + }, + style: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff2B353E), + letterSpacing: -0.44, + ), + decoration: InputDecoration( + isDense: true, + hintText: _hintText, + hintStyle: TextStyle( + fontSize: 14, + height: 21 / 14, + fontWeight: FontWeight.w400, + color: Color(0xff575757), + letterSpacing: -0.56, + ), + prefixIconConstraints: BoxConstraints(minWidth: 50), + + contentPadding: EdgeInsets.zero, + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + ), + ), + ], + ), + ), + if (hasSelection) Icon(Icons.keyboard_arrow_down_outlined), + ], + ), + ), + ); + } + } + class Language { final String name; final String value; diff --git a/lib/pages/login/register.dart b/lib/pages/login/register.dart index bdb2b623..7c6c08a5 100644 --- a/lib/pages/login/register.dart +++ b/lib/pages/login/register.dart @@ -349,12 +349,19 @@ class _Register extends State { cancelFunction: () {}) .showAlertDialog(context); } else { + final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy'); nRequest['forRegister'] = true; nRequest['isRegister'] = true; nRequest["PatientIdentificationID"] = nRequest["PatientIdentificationID"].toString(); + nRequest['dob'] = isHijri == 1 ? dob.text : dateFormat.format(selectedDate); + nRequest['isHijri'] = isHijri; sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, nRequest); sharedPref.setString(LOGIN_TOKEN_ID, response['LogInTokenID']); - this.chekUserData(response['LogInTokenID']); + if(request.patientOutSA ==0 ) { + this.chekUserData(response['LogInTokenID']); + }else{ + Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true, isDubai:true))); + } } } else { // if (response['ErrorCode'] == '-986') { diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index f833ad5d..d61e8ef7 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -247,7 +247,7 @@ class AuthProvider with ChangeNotifier { return Future.value(localRes); } - Future checkActivationCode(request, [value]) async { + Future checkActivationCode(request, [value]) async { var neRequest = CheckActivationCodeReq.fromJson(request); neRequest.activationCode = value ?? "0000"; @@ -376,10 +376,16 @@ class AuthProvider with ChangeNotifier { requestN.patientOutSA = requestN.patientobject.patientOutSA; final DateFormat dateFormat = DateFormat('MM/dd/yyyy'); final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy'); - requestN.dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format(dateFormat.parse(nhic['DateOfBirth'])); + if(nhic !=null) { + requestN.dob = nhic['IsHijri'] ? nhic['DateOfBirth'] : dateFormat2.format( + dateFormat.parse(nhic['DateOfBirth'])); + requestN.isHijri = nhic['IsHijri'] ? 1 : 0; + requestN.healthId = requestN.patientobject.eHealthIDField; + } + requestN.zipCode = requestN.patientOutSA == 1 ? '971' : '966'; - requestN.healthId = requestN.patientobject.eHealthIDField; - requestN.isHijri = nhic['IsHijri'] ? 1 : 0; + + await sharedPref.remove(USER_PROFILE); dynamic localRes; diff --git a/lib/services/clinic_services/get_clinic_service.dart b/lib/services/clinic_services/get_clinic_service.dart index 5079fc9b..8bf3a0ec 100644 --- a/lib/services/clinic_services/get_clinic_service.dart +++ b/lib/services/clinic_services/get_clinic_service.dart @@ -177,4 +177,14 @@ class ClinicListService extends BaseService { }, body: request); return Future.value(localRes); } + Future getCountries() async { + Map request ={}; + dynamic localRes; + await baseAppClient.post(GET_NATIONALITY, onSuccess: (response, statusCode) async { + localRes = response; + }, onFailure: (String error, int statusCode) { + throw error; + }, body: request); + return Future.value(localRes); +} }