diff --git a/lib/models/Authentication/check_activation_code_request.dart b/lib/models/Authentication/check_activation_code_request.dart index 71440dc4..a4bf79c3 100644 --- a/lib/models/Authentication/check_activation_code_request.dart +++ b/lib/models/Authentication/check_activation_code_request.dart @@ -22,7 +22,7 @@ class CheckActivationCodeReq { Null sessionID; bool isDentalAllowedBackend; int deviceTypeID; - + bool forRegisteration; CheckActivationCodeReq( {this.patientMobileNumber, this.mobileNo, @@ -46,7 +46,8 @@ class CheckActivationCodeReq { this.patientOutSA, this.sessionID, this.isDentalAllowedBackend, - this.deviceTypeID}); + this.deviceTypeID, + this.forRegisteration}); CheckActivationCodeReq.fromJson(Map json) { patientMobileNumber = json['PatientMobileNumber']; @@ -72,6 +73,7 @@ class CheckActivationCodeReq { sessionID = json['SessionID']; isDentalAllowedBackend = json['isDentalAllowedBackend']; deviceTypeID = json['DeviceTypeID']; + forRegisteration = json['ForRegisteration']; } Map toJson() { @@ -99,6 +101,7 @@ class CheckActivationCodeReq { data['SessionID'] = this.sessionID; data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['DeviceTypeID'] = this.deviceTypeID; + data['ForRegisteration'] = this.forRegisteration; return data; } } diff --git a/lib/models/Authentication/register_user_requet.dart b/lib/models/Authentication/register_user_requet.dart new file mode 100644 index 00000000..ebefcfcf --- /dev/null +++ b/lib/models/Authentication/register_user_requet.dart @@ -0,0 +1,151 @@ +class RegisterUserRequest { + Patientobject patientobject; + String patientIdentificationID; + int patientMobileNumber; + String logInTokenID; + double versionID; + int channel; + int languageID; + String iPAdress; + String generalid; + int patientOutSA; + Null sessionID; + bool isDentalAllowedBackend; + int deviceTypeID; + + RegisterUserRequest( + {this.patientobject, + this.patientIdentificationID, + this.patientMobileNumber, + this.logInTokenID, + this.versionID, + this.channel, + this.languageID, + this.iPAdress, + this.generalid, + this.patientOutSA, + this.sessionID, + this.isDentalAllowedBackend, + this.deviceTypeID}); + + RegisterUserRequest.fromJson(Map json) { + patientobject = json['Patientobject'] != null + ? new Patientobject.fromJson(json['Patientobject']) + : null; + patientIdentificationID = json['PatientIdentificationID']; + patientMobileNumber = json['PatientMobileNumber']; + logInTokenID = json['LogInTokenID']; + versionID = json['VersionID']; + channel = json['Channel']; + languageID = json['LanguageID']; + iPAdress = json['IPAdress']; + generalid = json['generalid']; + patientOutSA = json['PatientOutSA']; + sessionID = json['SessionID']; + isDentalAllowedBackend = json['isDentalAllowedBackend']; + deviceTypeID = json['DeviceTypeID']; + } + + Map toJson() { + final Map data = new Map(); + if (this.patientobject != null) { + data['Patientobject'] = this.patientobject.toJson(); + } + data['PatientIdentificationID'] = this.patientIdentificationID; + data['PatientMobileNumber'] = this.patientMobileNumber; + data['LogInTokenID'] = this.logInTokenID; + data['VersionID'] = this.versionID; + data['Channel'] = this.channel; + data['LanguageID'] = this.languageID; + data['IPAdress'] = this.iPAdress; + data['generalid'] = this.generalid; + data['PatientOutSA'] = this.patientOutSA; + data['SessionID'] = this.sessionID; + data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; + data['DeviceTypeID'] = this.deviceTypeID; + return data; + } +} + +class Patientobject { + bool tempValue; + int patientIdentificationType; + String patientIdentificationNo; + int mobileNumber; + int patientOutSA; + String firstName; + String middleName; + String lastName; + dynamic strDateofBirth; + String dateofBirth; + int gender; + String nationalityID; + String dateofBirthN; + String emailAddress; + String sourceType; + String preferredLanguage; + String marital; + + Patientobject( + {this.tempValue, + this.patientIdentificationType, + this.patientIdentificationNo, + this.mobileNumber, + this.patientOutSA, + this.firstName, + this.middleName, + this.lastName, + this.strDateofBirth, + this.dateofBirth, + this.gender, + this.nationalityID, + this.dateofBirthN, + this.emailAddress, + this.sourceType, + this.preferredLanguage, + this.marital}); + + Patientobject.fromJson(Map json) { + tempValue = json['TempValue']; + patientIdentificationType = json['PatientIdentificationType']; + patientIdentificationNo = json['PatientIdentificationNo']; + mobileNumber = json['MobileNumber']; + patientOutSA = json['PatientOutSA']; + firstName = json['FirstName']; + middleName = json['MiddleName']; + lastName = json['LastName']; + strDateofBirth = json['StrDateofBirth']; + dateofBirth = json['DateofBirth']; + gender = json['Gender']; + nationalityID = json['NationalityID']; + dateofBirthN = json['DateofBirthN']; + emailAddress = json['EmailAddress']; + sourceType = json['SourceType']; + + preferredLanguage = json['PreferredLanguage']; + marital = json['Marital']; + } + + Map toJson() { + final Map data = new Map(); + data['TempValue'] = this.tempValue; + data['PatientIdentificationType'] = this.patientIdentificationType; + data['PatientIdentificationNo'] = this.patientIdentificationNo; + data['MobileNumber'] = this.mobileNumber; + data['PatientOutSA'] = this.patientOutSA; + data['FirstName'] = this.firstName; + data['MiddleName'] = this.middleName; + data['LastName'] = this.lastName; + data['StrDateofBirth'] = this.strDateofBirth; + data['DateofBirth'] = this.dateofBirth; + data['Gender'] = this.gender; + data['NationalityID'] = this.nationalityID; + data['DateofBirthN'] = this.dateofBirthN; + data['EmailAddress'] = this.emailAddress; + data['SourceType'] = this.sourceType; + + data['PreferredLanguage'] = this.preferredLanguage; + data['Marital'] = this.marital; + return data; + } +} diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 609d16bc..a59258eb 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -37,7 +37,7 @@ class _ConfirmLogin extends State { String errorMsg = ''; SelectDeviceIMEIRES user; bool isLoading = false; - CheckPatientAuthenticationReq registerd_data; + var registerd_data; bool isMoreOption = false; var zipCode; @@ -119,9 +119,11 @@ class _ConfirmLogin extends State { textAlign: TextAlign.center, ), subtitle: Text( - formatDate(DateUtil - .convertStringToDate( - user.editedOn)), + user.editedOn != null + ? formatDate(DateUtil + .convertStringToDate( + user.editedOn)) + : '--', textAlign: TextAlign.center), )), @@ -418,14 +420,17 @@ class _ConfirmLogin extends State { // AuthenticationService.IMEI_USER_DATA, // false // ); + setState(() { setUser(); }); if (await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN) != null) { + isMoreOption = true; this.registerd_data = CheckPatientAuthenticationReq.fromJson( await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN)); } + this.mobileNumber = this.registerd_data != null ? this.registerd_data.patientMobileNumber : int.parse(this.user.mobile); @@ -456,7 +461,7 @@ class _ConfirmLogin extends State { request.loginType = this.selectedOption; request.oTPSendType = this.selectedOption == 1 ? 1 : 2; request.zipCode = this.zipCode; - request.isRegister = false; + request.logInTokenID = this.loginTokenID ?? ""; if (this.registerd_data != null) { @@ -464,45 +469,63 @@ class _ConfirmLogin extends State { request.patientID = this.registerd_data.patientID ?? 0; request.patientIdentificationID = request.nationalID = this.registerd_data.patientIdentificationID ?? '0'; + + request.isRegister = this.registerd_data.isRegister; } else { request.searchType = request.searchType ?? 2; request.patientID = this.user.patientID ?? 0; request.nationalID = request.nationalID ?? '0'; request.patientIdentificationID = request.patientIdentificationID ?? '0'; + request.isRegister = false; } request.deviceTypeID = request.searchType; return request; } - checkActivationCode({value}) { + checkActivationCode({value}) async { SMSOTP.showLoadingDialog(context, true); var request = this.getCommonRequest().toJson(); - this.authService.checkActivationCode(request, value: value).then((result) => - { - if (result is Map) - { - result = CheckActivationCode.fromJson(result), - - this.userData = - result.list, //AuthenticatedUser.fromJson(result['List'][0]), - this.sharedPref.setObject(USER_PROFILE, result.list), - this.loginTokenID = result.logInTokenID, - this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), - this.sharedPref.setString(TOKEN, result.authenticationTokenID), - this.checkIfUserAgreedBefore(result), - // Navigator.of(context).pop(), - SMSOTP.showLoadingDialog(context, false), - } - else - { - // Navigator.of(context).pop(), - SMSOTP.showLoadingDialog(context, false), - Future.delayed(Duration(seconds: 1), () { - AppToast.showErrorToast(message: result); - }), - } - }); + this + .authService + .checkActivationCode(request, value: value) + .then((result) => { + if (result is Map) + { + result = CheckActivationCode.fromJson(result), + if (this.registerd_data != null && + this.registerd_data.isRegister == true) + { + Navigator.of(context).pushNamed( + REGISTER_INFO, + ) + } + else + { + this.userData = result + .list, //AuthenticatedUser.fromJson(result['List'][0]), + this.sharedPref.setObject(USER_PROFILE, result.list), + this.loginTokenID = result.logInTokenID, + this + .sharedPref + .setObject(LOGIN_TOKEN_ID, result.logInTokenID), + this + .sharedPref + .setString(TOKEN, result.authenticationTokenID), + this.checkIfUserAgreedBefore(result), + // Navigator.of(context).pop(), + SMSOTP.showLoadingDialog(context, false), + } + } + else + { + // Navigator.of(context).pop(), + SMSOTP.showLoadingDialog(context, false), + Future.delayed(Duration(seconds: 1), () { + AppToast.showErrorToast(message: result); + }), + } + }); } checkIfUserAgreedBefore(CheckActivationCode result) { @@ -519,7 +542,7 @@ class _ConfirmLogin extends State { } goToHome() { - authService.insertDeviceImei().then((value) => print(value)); + // authService.insertDeviceImei().then((value) => print(value)); Navigator.of(context).pushNamed(HOME); // const request = new LoginRequest(); // if (this.loginType === AuthenticationService.IDENTIFCIATION_LOGIN_TYPE) { diff --git a/lib/pages/login/register-info.dart b/lib/pages/login/register-info.dart index 70e5fb29..24d1a85c 100644 --- a/lib/pages/login/register-info.dart +++ b/lib/pages/login/register-info.dart @@ -1,10 +1,14 @@ import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/config/size_config.dart'; +import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/register_info_response.dart'; +import 'package:diplomaticquarterapp/models/Authentication/register_user_requet.dart'; import 'package:diplomaticquarterapp/pages/login/login-type.dart'; +import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_toast.dart'; +import 'package:diplomaticquarterapp/uitl/date_uitl.dart'; import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:diplomaticquarterapp/uitl/utils.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; @@ -13,9 +17,12 @@ import 'package:diplomaticquarterapp/widgets/card/rounded_container.dart'; import 'package:diplomaticquarterapp/widgets/input/text_field.dart'; import 'package:diplomaticquarterapp/widgets/mobile-no/mobile_no.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/progress_indicator/app_circular_progress_Indeicator.dart'; import 'package:diplomaticquarterapp/widgets/text/app_texts_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:hijri/hijri_calendar.dart'; +import 'package:intl/intl.dart'; class RegisterInfo extends StatefulWidget { @override @@ -25,9 +32,14 @@ class RegisterInfo extends StatefulWidget { class _RegisterInfo extends State { final authService = new AuthProvider(); final sharedPref = new AppSharedPreferences(); + var emailAddress = new TextEditingController(); RegisterInfoResponse registerInfo; bool isLoading; int page = 1; + String selectedLanguage = 'English'; + var registerRequest; + + var selectSourceType = 'KSA'; @override void initState() { getRegisterInfo(); @@ -41,100 +53,289 @@ class _RegisterInfo extends State { isShowAppBar: true, body: SingleChildScrollView( child: Container( - padding: EdgeInsets.only(top: 10, left: 20, right: 20, bottom: 30), - height: SizeConfig.realScreenHeight * .9, + // padding: EdgeInsets.only(top: 10, left: 10, right: 10, bottom: 30), + height: SizeConfig.realScreenHeight, width: SizeConfig.realScreenWidth, - child: Column(children: [ - Expanded( - flex: 1, - child: AppText( - TranslationBase.of(context).patientInfo, - fontSize: SizeConfig.textMultiplier * 3, - textAlign: TextAlign.left, - )), - registerInfo != null && page == 1 - ? Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, + child: RoundedContainer( + child: Padding( + padding: + EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 0), + child: Stack( + // crossAxisAlignment: CrossAxisAlignment.start, + // mainAxisAlignment: MainAxisAlignment.start, children: [ - AppText('National ID'), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.idNumber, - prefixIcon: Icon(Icons.chrome_reader_mode, - color: Colors.red), - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText('Name'), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.firstNameEn + - ' ' + - registerInfo.lastNameEn, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText('Gender'), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.maritalStatusCode == 'U' - ? 'Unknown' - : registerInfo.maritalStatusCode == 'M' - ? 'Male' - : 'Female', - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText('Nationality'), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.nationalityCode, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, - )), - AppText('Date of Birth'), - Container( - margin: EdgeInsets.only(bottom: 10), - child: TextFields( - hintText: registerInfo.dateOfBirth, - padding: EdgeInsets.only( - top: 20, bottom: 20, left: 10, right: 10), - readOnly: true, + Padding( + padding: EdgeInsets.only(bottom: 0), + child: AppText( + TranslationBase.of(context).patientInfo, + fontWeight: FontWeight.bold, + // fontSize: SizeConfig.textMultiplier * 2, + textAlign: TextAlign.left, )), + registerInfo != null && page == 1 + ? Padding( + padding: EdgeInsets.only(top: 20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.idNumber, + prefixIcon: Icon( + Icons.chrome_reader_mode, + color: Colors.red), + padding: EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), + readOnly: true, + )), + AppText('First Name'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.firstNameEn, + padding: EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), + readOnly: true, + )), + AppText('Middle Name'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.secondNameEn, + padding: EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), + readOnly: true, + )), + AppText('Last Name'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.lastNameEn, + padding: EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), + readOnly: true, + )), + AppText('Gender'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo + .maritalStatusCode == + 'U' + ? 'Unknown' + : registerInfo.maritalStatusCode == + 'M' + ? 'Male' + : 'Female', + padding: EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), + readOnly: true, + )), + AppText('Nationality'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.nationalityCode, + padding: EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), + readOnly: true, + )), + AppText('Date of Birth'), + Container( + margin: EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: registerInfo.dateOfBirth, + padding: EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), + readOnly: true, + )), + ], + )) + : registerInfo != null && page == 2 + ? isLoading == true + ? AppCircularProgressIndicator() + : Padding( + padding: EdgeInsets.only(top: 20), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + AppText('Preferred Language'), + Container( + margin: EdgeInsets.only(top: 0), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey, + width: 1), + borderRadius: + BorderRadius.circular( + 5.0)), + padding: EdgeInsets.all(5), + child: + DropdownButtonHideUnderline( + child: DropdownButton( + focusColor: + Colors.white, + dropdownColor: + Colors.white, + isExpanded: true, + value: + selectedLanguage, + iconSize: 40, + elevation: 16, + onChanged: (String + newValue) => + {}, + items: [ + 'English', + 'Arabic', + ].map< + DropdownMenuItem< + String>>((String + value) { + return DropdownMenuItem< + String>( + value: value, + child: + Text(value), + ); + }).toList()))), + AppText( + 'Where do you want to create this file?'), + Container( + margin: + EdgeInsets.only(bottom: 10), + decoration: BoxDecoration( + border: Border.all( + color: Colors.grey, + width: 1), + borderRadius: + BorderRadius.circular( + 5.0)), + padding: EdgeInsets.all(5), + child: + DropdownButtonHideUnderline( + child: DropdownButton( + focusColor: + Colors.white, + dropdownColor: + Colors.white, + isExpanded: true, + value: + selectSourceType, + iconSize: 40, + elevation: 16, + onChanged: (String + newValue) => + {}, + items: [ + 'KSA', + 'Dubai', + ].map< + DropdownMenuItem< + String>>((String + value) { + return DropdownMenuItem< + String>( + value: value, + child: + Text(value), + ); + }).toList()))), + AppText('Email'), + Container( + margin: + EdgeInsets.only(bottom: 10), + child: TextFields( + hintText: 'Email', + controller: emailAddress, + padding: EdgeInsets.only( + top: 20, + bottom: 20, + left: 10, + right: 10), + )) + ], + )) + : SizedBox(), + // AppText('National ID'), + + page == 1 + ? Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: DefaultButton( + TranslationBase.of(context).next, + () => {nextPage()}, + textColor: Colors.white, + )) + ], + ) + ], + ) + : Column( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + Row( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Expanded( + child: DefaultButton( + TranslationBase.of(context).register, + () => {registerNow()}, + textColor: Colors.white, + )) + ]) + ]) ], - ) - : registerInfo != null && page == 2 - ? Column( - children: [], - ) - : SizedBox(), - Expanded( - flex: 2, - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - children: [ - Row( - children: [ - Expanded( - child: DefaultButton( - TranslationBase.of(context).next, - () => {nextPage()}, - textColor: Colors.white, - )) - ], - ), - ], - )) - ]), + ))), + // Expanded( + // flex: 2, + // child: Column( + // mainAxisAlignment: MainAxisAlignment.end, + // children: [ + // Row( + // children: [ + // Expanded( + // child: DefaultButton( + // TranslationBase.of(context).next, + // () => {nextPage()}, + // textColor: Colors.white, + // )) + // ], + // ), + // ], + // )) ))); } @@ -144,11 +345,89 @@ class _RegisterInfo extends State { }); } - registerNow() {} + registerNow() { + var patientRequest = Patientobject(); + var request = RegisterUserRequest(); + showLoader(true); + patientRequest.dateofBirth = DateUtil.convertISODateToJsonDate( + registerInfo.dateOfBirth.replaceAll('/', '-')); + patientRequest.emailAddress = emailAddress.text; + patientRequest.patientIdentificationNo = registerInfo.idNumber; + patientRequest.patientIdentificationType = 2; + patientRequest.sourceType = selectSourceType == 'KSA' ? '1' : '2'; + patientRequest.nationalityID = registerInfo.nationalityCode; + patientRequest.dateofBirthN = HijriCalendar.fromDate(DateFormat('mm-dd-yyy') + .parse(registerInfo.dateOfBirth.replaceAll('/', '-'))) + .toString(); + patientRequest.firstName = registerInfo.firstNameEn; + patientRequest.middleName = registerInfo.secondNameEn; + patientRequest.lastName = registerInfo.lastNameEn; + patientRequest.gender = registerInfo.gender == 'F' ? 2 : 1; + patientRequest.mobileNumber = registerRequest['PatientMobileNumber']; + patientRequest.marital = registerInfo.maritalStatusCode == 'M' ? '1' : '0'; + // patientRequest.projectID = null; + patientRequest.strDateofBirth = DateFormat('mm-dd-yyy') + .parse(registerInfo.dateOfBirth.replaceAll('/', '-')) + .toString(); //DateFormat("MM-dd-yyyy") + //.parse(registerInfo.dateOfBirth.replaceAll('/', '-')); + patientRequest.tempValue = true; + request.logInTokenID = registerRequest['LogInTokenID']; + request.patientMobileNumber = registerRequest['PatientMobileNumber']; + request.patientIdentificationID = registerInfo.idNumber; + request.patientOutSA = registerRequest['PatientOutSA']; + request.patientobject = patientRequest; + request.patientobject.preferredLanguage = + selectedLanguage == 'Arabic' ? '1' : '2'; + authService.registerUser(request).then((value) => {registerd(value)}); + } + + registerd(result) { + showLoader(false); + if (result is Map) { + result = CheckActivationCode.fromJson(result); + + // this.userData = + // result.list; //AuthenticatedUser.fromJson(result['List'][0]), + this.sharedPref.setObject(USER_PROFILE, result.list); + // this.loginTokenID = result.logInTokenID; + this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID); + this.sharedPref.setString(TOKEN, result.authenticationTokenID); + this.checkIfUserAgreedBefore(result); + // Navigator.of(context).pop(), + + } else { + // Navigator.of(context).pop(), + AppToast.showErrorToast(message: result); + } + } + + checkIfUserAgreedBefore(result) { + if (result.isNeedUserAgreement) { + //move to agreement page. + } else { + insertIMEI(); + } + } + + insertIMEI() { + authService + .insertDeviceImei() + .then((value) => {Navigator.of(context).pushNamed(HOME)}); + } + getRegisterInfo() async { registerInfo = RegisterInfoResponse.fromJson(await sharedPref.getObject(NHIC_DATA)); - + registerRequest = await sharedPref.getObject(REGISTER_DATA_FOR_LOGIIN); + setState(() { + registerInfo = registerInfo; + }); print(await sharedPref.getObject(NHIC_DATA)); } + + showLoader(bool isTrue) { + setState(() { + isLoading = isTrue; + }); + } } diff --git a/lib/pages/login/register.dart b/lib/pages/login/register.dart index 5197b652..c6c4ffa3 100644 --- a/lib/pages/login/register.dart +++ b/lib/pages/login/register.dart @@ -185,6 +185,7 @@ class _Register extends State { // if (this.loginType == 1) { request.patientIdentificationID = int.parse(nationalIDorFile.text); request.patientID = 0; + request.isRegister = true; // } else { // request.patientIdentificationID = 0; // request.patientID = int.parse(nationalIDorFile.text); @@ -223,18 +224,19 @@ class _Register extends State { nRequest['LogInTokenID'] = response['LogInTokenID']; if (response['hasFile'] == true) { AppToast.showErrorToast(message: response['ErrorEndUserMessage']); - //confirm box need to implement - // this.cs.confirmLogin(); } else { nRequest['forRegister'] = true; + nRequest['isRegister'] = true; + nRequest["PatientIdentificationID"] = + nRequest["PatientIdentificationID"].toString(); sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, nRequest); - + sharedPref.setString(LOGIN_TOKEN_ID, response['LogInTokenID']); this.chekUserData(response['LogInTokenID']); } } else { - if (response['ErrorCode'] == '-986') { - AppToast.showErrorToast(message: response['ErrorEndUserMessage']); - } + // if (response['ErrorCode'] == '-986') { + AppToast.showErrorToast(message: response); + //} } } @@ -262,8 +264,11 @@ class _Register extends State { result = CheckUserStatusResponse.fromJson(result), sharedPref.setObject(NHIC_DATA, result), Navigator.of(context).pushNamed( - REGISTER_INFO, + CONFIRM_LOGIN, ) + // Navigator.of(context).pushNamed( + // REGISTER_INFO, + // ) } else {AppToast.showErrorToast(message: result['ErrorEndUserMessage'])} diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 4b0717b4..4001d8fd 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -8,14 +8,11 @@ import 'package:diplomaticquarterapp/models/Authentication/check_activation_code import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/check_user_status_req.dart'; import 'package:diplomaticquarterapp/models/Authentication/checkpatient_for_registration.dart'; -import 'package:diplomaticquarterapp/models/Authentication/get_mobile_info_request.dart'; -import 'package:diplomaticquarterapp/models/Authentication/get_mobile_info_response.dart'; import 'package:diplomaticquarterapp/models/Authentication/insert_device_imei_request.dart'; +import 'package:diplomaticquarterapp/models/Authentication/register_user_requet.dart'; import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart'; import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart'; -import 'package:diplomaticquarterapp/models/Request.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; -import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart'; import 'package:flutter/cupertino.dart'; // SharedPreferences sharedPref = new SharedPreferences(); @@ -35,6 +32,7 @@ const CHECK_PATIENT_FOR_REGISTRATION = "/Authentication.svc/REST/CheckPatientForRegisteration"; const CHECK_USER_STATUS = "/NHIC.svc/REST/GetPatientInfo"; +const REGISTER_USER = '/Authentication.svc/REST/PatientRegistration'; class AuthProvider with ChangeNotifier { bool isLogin = false; @@ -223,7 +221,6 @@ class AuthProvider with ChangeNotifier { var neRequest = CheckActivationCodeReq.fromJson(request); neRequest.activationCode = value ?? "0000"; neRequest.isSilentLogin = value != null ? false : true; - neRequest.isRegister = false; neRequest.versionID = VERSION_ID; neRequest.channel = CHANNEL; neRequest.iPAdress = IP_ADDRESS; @@ -233,6 +230,8 @@ class AuthProvider with ChangeNotifier { neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1; neRequest.projectOutSA = neRequest.zipCode == '966' ? 0 : 1; neRequest.isDentalAllowedBackend = false; + neRequest.forRegisteration = neRequest.isRegister; + neRequest.isRegister = false; dynamic localRes; try { await new BaseAppClient().post(CHECK_ACTIVATION_CODE, @@ -303,4 +302,28 @@ class AuthProvider with ChangeNotifier { throw error; } } + + Future registerUser(RegisterUserRequest request) async { + request.versionID = VERSION_ID; + request.channel = CHANNEL; + request.iPAdress = IP_ADDRESS; + request.generalid = GENERAL_ID; + request.deviceTypeID = DeviceTypeID; + request.languageID = LANGUAGE_ID; + + // request.tokenID = ''; + dynamic localRes; + try { + await new BaseAppClient().post(REGISTER_USER, + onSuccess: (dynamic response, int statusCode) { + localRes = response; + }, onFailure: (String error, int statusCode) { + localRes = error; + return Future.value(error); + }, body: request.toJson()); + return Future.value(localRes); + } catch (error) { + throw error; + } + } } diff --git a/lib/uitl/date_uitl.dart b/lib/uitl/date_uitl.dart index c70e05b7..635776ac 100644 --- a/lib/uitl/date_uitl.dart +++ b/lib/uitl/date_uitl.dart @@ -1,5 +1,6 @@ -class DateUtil { +import 'package:intl/intl.dart'; +class DateUtil { /// convert String To Date function /// [date] String we want to convert static DateTime convertStringToDate(String date) { @@ -91,7 +92,6 @@ class DateUtil { } } - /// get data formatted like Apr 26,2020 /// [dateTime] convert DateTime to data formatted static String getMonthDayYearDateFormatted(DateTime dateTime) { @@ -105,7 +105,6 @@ class DateUtil { return ""; } - /// get data formatted like 26/4/2020 /// [dateTime] convert DateTime to data formatted static String getDayMonthYearDateFormatted(DateTime dateTime) { @@ -119,4 +118,13 @@ class DateUtil { else return ""; } + + static convertISODateToJsonDate(String isoDate) { + return "/Date(" + + DateFormat('mm-dd-yyy') + .parse(isoDate) + .millisecondsSinceEpoch + .toString() + + ")/"; + } } diff --git a/lib/widgets/drawer/app_drawer_widget.dart b/lib/widgets/drawer/app_drawer_widget.dart index 260f5851..3d856574 100644 --- a/lib/widgets/drawer/app_drawer_widget.dart +++ b/lib/widgets/drawer/app_drawer_widget.dart @@ -235,6 +235,7 @@ class _AppDrawerState extends State { login() async { var data = await sharedPref.getObject(IMEI_USER_DATA); + sharedPref.remove(REGISTER_DATA_FOR_LOGIIN); if (data != null) { Navigator.of(context).pushNamed(CONFIRM_LOGIN); } else { diff --git a/pubspec.yaml b/pubspec.yaml index 50784aa5..e2735c4f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -80,7 +80,8 @@ dependencies: # Location Helper map_launcher: ^0.8.1 - + #hijri + hijri: ^2.0.3