diff --git a/lib/config/shared_pref_kay.dart b/lib/config/shared_pref_kay.dart index a4f11077..cbf523bd 100644 --- a/lib/config/shared_pref_kay.dart +++ b/lib/config/shared_pref_kay.dart @@ -8,3 +8,4 @@ const REGISTER_DATA_FOR_LOGIIN = 'register-data-for-login'; const LAST_LOGIN = 'last-login'; const ONLY_SMS = 'only-sms'; const AUTH_DATA = 'auth-data'; +const IMEI_USER_DATA = 'imei-user-data'; diff --git a/lib/models/Authentication/insert_device_imei_request.dart b/lib/models/Authentication/insert_device_imei_request.dart index 474e6194..02e3b278 100644 --- a/lib/models/Authentication/insert_device_imei_request.dart +++ b/lib/models/Authentication/insert_device_imei_request.dart @@ -3,69 +3,14 @@ class INSERTDeviceIMEIRequest { int patientType; int patientID; String firstName; - String middleName; - String lastName; String firstNameN; - String middleNameN; String lastNameN; - int relationshipID; - int gender; - String dateofBirth; - Null dateofBirthN; - String nationalityID; - Null phoneResi; - Null phoneOffice; - String mobileNumber; - Null faxNumber; - String emailAddress; - Null bloodGroup; - Null rHFactor; - bool isEmailAlertRequired; - bool isSMSAlertRequired; int preferredLanguage; - bool isPrivilegedMember; - Null memberID; - Null expiryDate; - Null isHmgEmployee; - Null employeeID; - Null emergencyContactName; - Null emergencyContactNo; - int patientPayType; - Null dHCCPatientRefID; - bool isPatientDummy; - int status; - Null isStatusCleared; - int patientIdentificationType; String patientIdentificationNo; - int projectID; - int infoSourceID; - Null address; - int age; - String ageDesc; - int areaID; - int createdBy; - String genderDescription; - Null iR; - Null iSOCityID; - Null iSOCountryID; - List listPrivilege; - Null marital; bool outSA; - Null pOBox; - bool receiveHealthSummaryReport; - int sourceType; - Null strDateofBirth; - Null tempAddress; - String zipCode; - - String patientName; String identificationNo; - Null email; String mobileNo; - bool patientOutSA; - String tokenID; - Null patientBloodType; String iMEI; bool biometricEnabled; int logInTypeID; @@ -75,67 +20,14 @@ class INSERTDeviceIMEIRequest { this.patientType, this.patientID, this.firstName, - this.middleName, - this.lastName, this.firstNameN, - this.middleNameN, this.lastNameN, - this.relationshipID, - this.gender, - this.dateofBirth, - this.dateofBirthN, - this.nationalityID, - this.phoneResi, - this.phoneOffice, - this.mobileNumber, - this.faxNumber, - this.emailAddress, - this.bloodGroup, - this.rHFactor, - this.isEmailAlertRequired, - this.isSMSAlertRequired, this.preferredLanguage, - this.isPrivilegedMember, - this.memberID, - this.expiryDate, - this.isHmgEmployee, - this.employeeID, - this.emergencyContactName, - this.emergencyContactNo, - this.patientPayType, - this.dHCCPatientRefID, - this.isPatientDummy, - this.status, - this.isStatusCleared, - this.patientIdentificationType, this.patientIdentificationNo, - this.projectID, - this.infoSourceID, - this.address, - this.age, - this.ageDesc, - this.areaID, - this.createdBy, - this.genderDescription, - this.iR, - this.iSOCityID, - this.iSOCountryID, - this.listPrivilege, - this.marital, this.outSA, - this.pOBox, - this.receiveHealthSummaryReport, - this.sourceType, - this.strDateofBirth, - this.tempAddress, - this.zipCode, - this.patientName, this.identificationNo, - this.email, this.mobileNo, - this.patientOutSA, this.tokenID, - this.patientBloodType, this.iMEI, this.biometricEnabled, this.logInTypeID}); @@ -145,74 +37,14 @@ class INSERTDeviceIMEIRequest { patientType = json['PatientType']; patientID = json['PatientID']; firstName = json['FirstName']; - middleName = json['MiddleName']; - lastName = json['LastName']; firstNameN = json['FirstNameN']; - middleNameN = json['MiddleNameN']; lastNameN = json['LastNameN']; - relationshipID = json['RelationshipID']; - gender = json['Gender']; - dateofBirth = json['DateofBirth']; - dateofBirthN = json['DateofBirthN']; - nationalityID = json['NationalityID']; - phoneResi = json['PhoneResi']; - phoneOffice = json['PhoneOffice']; - mobileNumber = json['MobileNumber']; - faxNumber = json['FaxNumber']; - emailAddress = json['EmailAddress']; - bloodGroup = json['BloodGroup']; - rHFactor = json['RHFactor']; - isEmailAlertRequired = json['IsEmailAlertRequired']; - isSMSAlertRequired = json['IsSMSAlertRequired']; preferredLanguage = json['PreferredLanguage']; - isPrivilegedMember = json['IsPrivilegedMember']; - memberID = json['MemberID']; - expiryDate = json['ExpiryDate']; - isHmgEmployee = json['IsHmgEmployee']; - employeeID = json['EmployeeID']; - emergencyContactName = json['EmergencyContactName']; - emergencyContactNo = json['EmergencyContactNo']; - patientPayType = json['PatientPayType']; - dHCCPatientRefID = json['DHCCPatientRefID']; - isPatientDummy = json['IsPatientDummy']; - status = json['Status']; - isStatusCleared = json['IsStatusCleared']; - patientIdentificationType = json['PatientIdentificationType']; patientIdentificationNo = json['PatientIdentificationNo']; - projectID = json['ProjectID']; - infoSourceID = json['InfoSourceID']; - address = json['Address']; - age = json['Age']; - ageDesc = json['AgeDesc']; - areaID = json['AreaID']; - createdBy = json['CreatedBy']; - genderDescription = json['GenderDescription']; - iR = json['IR']; - iSOCityID = json['ISOCityID']; - iSOCountryID = json['ISOCountryID']; - if (json['ListPrivilege'] != null) { - listPrivilege = new List(); - json['ListPrivilege'].forEach((v) { - listPrivilege.add(new ListPrivilege.fromJson(v)); - }); - } - marital = json['Marital']; outSA = json['OutSA']; - pOBox = json['POBox']; - receiveHealthSummaryReport = json['ReceiveHealthSummaryReport']; - sourceType = json['SourceType']; - strDateofBirth = json['StrDateofBirth']; - tempAddress = json['TempAddress']; - zipCode = json['ZipCode']; - - patientName = json['PatientName']; identificationNo = json['IdentificationNo']; - email = json['Email']; mobileNo = json['MobileNo']; - patientOutSA = json['PatientOutSA']; - tokenID = json['TokenID']; - patientBloodType = json['PatientBloodType']; iMEI = json['IMEI']; biometricEnabled = json['BiometricEnabled']; logInTypeID = json['LogInTypeID']; @@ -224,100 +56,17 @@ class INSERTDeviceIMEIRequest { data['PatientType'] = this.patientType; data['PatientID'] = this.patientID; data['FirstName'] = this.firstName; - data['MiddleName'] = this.middleName; - data['LastName'] = this.lastName; data['FirstNameN'] = this.firstNameN; - data['MiddleNameN'] = this.middleNameN; data['LastNameN'] = this.lastNameN; - data['RelationshipID'] = this.relationshipID; - data['Gender'] = this.gender; - data['DateofBirth'] = this.dateofBirth; - data['DateofBirthN'] = this.dateofBirthN; - data['NationalityID'] = this.nationalityID; - data['PhoneResi'] = this.phoneResi; - data['PhoneOffice'] = this.phoneOffice; - data['MobileNumber'] = this.mobileNumber; - data['FaxNumber'] = this.faxNumber; - data['EmailAddress'] = this.emailAddress; - data['BloodGroup'] = this.bloodGroup; - data['RHFactor'] = this.rHFactor; - data['IsEmailAlertRequired'] = this.isEmailAlertRequired; - data['IsSMSAlertRequired'] = this.isSMSAlertRequired; data['PreferredLanguage'] = this.preferredLanguage; - data['IsPrivilegedMember'] = this.isPrivilegedMember; - data['MemberID'] = this.memberID; - data['ExpiryDate'] = this.expiryDate; - data['IsHmgEmployee'] = this.isHmgEmployee; - data['EmployeeID'] = this.employeeID; - data['EmergencyContactName'] = this.emergencyContactName; - data['EmergencyContactNo'] = this.emergencyContactNo; - data['PatientPayType'] = this.patientPayType; - data['DHCCPatientRefID'] = this.dHCCPatientRefID; - data['IsPatientDummy'] = this.isPatientDummy; - data['Status'] = this.status; - data['IsStatusCleared'] = this.isStatusCleared; - data['PatientIdentificationType'] = this.patientIdentificationType; data['PatientIdentificationNo'] = this.patientIdentificationNo; - data['ProjectID'] = this.projectID; - data['InfoSourceID'] = this.infoSourceID; - data['Address'] = this.address; - data['Age'] = this.age; - data['AgeDesc'] = this.ageDesc; - data['AreaID'] = this.areaID; - data['CreatedBy'] = this.createdBy; - data['GenderDescription'] = this.genderDescription; - data['IR'] = this.iR; - data['ISOCityID'] = this.iSOCityID; - data['ISOCountryID'] = this.iSOCountryID; - if (this.listPrivilege != null) { - data['ListPrivilege'] = - this.listPrivilege.map((v) => v.toJson()).toList(); - } - data['Marital'] = this.marital; data['OutSA'] = this.outSA; - data['POBox'] = this.pOBox; - data['ReceiveHealthSummaryReport'] = this.receiveHealthSummaryReport; - data['SourceType'] = this.sourceType; - data['StrDateofBirth'] = this.strDateofBirth; - data['TempAddress'] = this.tempAddress; - data['ZipCode'] = this.zipCode; - - data['PatientName'] = this.patientName; data['IdentificationNo'] = this.identificationNo; - data['Email'] = this.email; data['MobileNo'] = this.mobileNo; - data['PatientOutSA'] = this.patientOutSA; - data['TokenID'] = this.tokenID; - data['PatientBloodType'] = this.patientBloodType; data['IMEI'] = this.iMEI; data['BiometricEnabled'] = this.biometricEnabled; data['LogInTypeID'] = this.logInTypeID; return data; } } - -class ListPrivilege { - int iD; - String serviceName; - bool previlege; - Null region; - - ListPrivilege({this.iD, this.serviceName, this.previlege, this.region}); - - ListPrivilege.fromJson(Map json) { - iD = json['ID']; - serviceName = json['ServiceName']; - previlege = json['Previlege']; - region = json['Region']; - } - - Map toJson() { - final Map data = new Map(); - data['ID'] = this.iD; - data['ServiceName'] = this.serviceName; - data['Previlege'] = this.previlege; - data['Region'] = this.region; - return data; - } -} diff --git a/lib/pages/landing/landing_page.dart b/lib/pages/landing/landing_page.dart index bf1ac847..ef36b0ef 100644 --- a/lib/pages/landing/landing_page.dart +++ b/lib/pages/landing/landing_page.dart @@ -97,7 +97,8 @@ class _LandingPageState extends State { .then((SelectDeviceIMEIRES value) => setUserValues(value)); } - void setUserValues(value) { + void setUserValues(value) async { print(value); + sharedPref.setObject(IMEI_USER_DATA, value); } } diff --git a/lib/pages/login/confirm-login.dart b/lib/pages/login/confirm-login.dart index 3d5f181e..7d011fbd 100644 --- a/lib/pages/login/confirm-login.dart +++ b/lib/pages/login/confirm-login.dart @@ -54,6 +54,10 @@ class _ConfirmLogin extends State { bool onlySMSBox = false; var userData; + + static BuildContext _context; + + static bool _loading; @override void initState() { _getAvailableBiometrics(); @@ -509,15 +513,17 @@ class _ConfirmLogin extends State { } checkActivationCode({value}) { - loading(true); + SMSOTP.showLoadingDialog(context, true); var request = this.getCommonRequest().toJson(); this.authService.checkActivationCode(request, value).then((result) => { this.userData = result.list, //AuthenticatedUser.fromJson(result['List'][0]), this.sharedPref.setObject(USER_PROFILE, result.list), this.sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID), + this.sharedPref.setString(TOKEN, result.authenticationTokenID), this.checkIfUserAgreedBefore(result), - loading(false) + Navigator.of(context).pop(), + SMSOTP.showLoadingDialog(context, false), }); } @@ -526,13 +532,17 @@ class _ConfirmLogin extends State { if (result.isNeedUserAgreement) { //move to agreement page. } else { - goToHome(); + insertIMEI(); } } + insertIMEI() { + authService.insertDeviceImei().then((value) => {goToHome()}); + } + goToHome() { authService.insertDeviceImei().then((value) => print(value)); - // Navigator.of(context).pushNamed(HOME); + Navigator.of(context).pushNamed(HOME); // const request = new LoginRequest(); // if (this.loginType === AuthenticationService.IDENTIFCIATION_LOGIN_TYPE) { // request.PatientID = 0; diff --git a/lib/services/authentication/auth_provider.dart b/lib/services/authentication/auth_provider.dart index 40e76236..0e35964d 100644 --- a/lib/services/authentication/auth_provider.dart +++ b/lib/services/authentication/auth_provider.dart @@ -33,7 +33,7 @@ const CHECK_ACTIVATION_CODE = '/Authentication.svc/REST/CheckActivationCode'; class AuthProvider with ChangeNotifier { bool isLogin = false; bool isLoading = true; - var authenticatedUser; + dynamic authenticatedUser; AuthProvider() { getUserAuthentication(); } @@ -89,6 +89,7 @@ class AuthProvider with ChangeNotifier { var request = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE)); var newRequest = INSERTDeviceIMEIRequest(); + var imei = await sharedPref.getString(PUSH_TOKEN); // if (!request.) { newRequest.iMEI = imei; @@ -99,6 +100,13 @@ class AuthProvider with ChangeNotifier { newRequest.biometricEnabled = false; newRequest.preferredLanguage = int.parse(request.preferredLanguage) ?? 1; newRequest.logInTypeID = lastLogin ?? 1; + newRequest.patientID = request.patientID; + newRequest.mobileNo = request.mobileNumber; + newRequest.identificationNo = request.patientIdentificationNo; + newRequest.patientIdentificationNo = request.patientIdentificationNo; + newRequest.patientType = request.patientType; + newRequest.setupID = request.setupID; + newRequest.tokenID = await sharedPref.getString(TOKEN); // } await new BaseAppClient().post(INSERT_DEVICE_IMEI, @@ -121,7 +129,8 @@ class AuthProvider with ChangeNotifier { request['IMEI'] = imei; await new BaseAppClient().post(SELECT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) { - localRes = response; + localRes = SelectDeviceIMEIRES.fromJson( + response['Patient_SELECTDeviceIMEIbyIMEIList'][0]); }, onFailure: (String error, int statusCode) { throw error; }, body: request); @@ -189,7 +198,7 @@ class AuthProvider with ChangeNotifier { request.patientOutSA = request.zipCode == '966' ? 0 : 1; request.isDentalAllowedBackend = false; try { - var localRes; + dynamic localRes; await new BaseAppClient().post(SEND_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) { localRes = response; diff --git a/lib/widgets/otp/sms-popup.dart b/lib/widgets/otp/sms-popup.dart index 6d93552b..75a2eda7 100644 --- a/lib/widgets/otp/sms-popup.dart +++ b/lib/widgets/otp/sms-popup.dart @@ -17,6 +17,10 @@ class SMSOTP { Future timer; + static BuildContext _context; + + static bool _loading; + SMSOTP( this.context, this.type, @@ -277,4 +281,29 @@ class SMSOTP { } }); } + + static void showLoadingDialog(BuildContext context, bool _loading) async { + _context = context; + _loading = true; + if (_loading == false) { + Navigator.of(context).pop(); + return; + } + await showDialog( + context: _context, + barrierDismissible: false, + builder: (BuildContext context) { + return SimpleDialog( + elevation: 0.0, + backgroundColor: Colors.transparent, + children: [ + Center( + child: CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation(Colors.black), + ), + ) + ], + ); + }); + } }