From 0c58c22ea552eb86dbb036d1a37d7ff1c7af98e0 Mon Sep 17 00:00:00 2001 From: aamir-csol Date: Thu, 11 Sep 2025 09:32:57 +0300 Subject: [PATCH 1/2] sign --- lib/core/api_consts.dart | 2 +- .../authentication_view_model.dart | 102 +++++++++--------- lib/widgets/loader/bottomsheet_loader.dart | 4 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index bad2e4c..42f10f4 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -726,7 +726,7 @@ const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_In class ApiConsts { static const maxSmallScreen = 660; - static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; + static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat; // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 95f821f..2327c37 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -82,7 +82,7 @@ class AuthenticationViewModel extends ChangeNotifier { String errorMsg = ''; final FocusNode myFocusNode = FocusNode(); var healthId; - int getDeviceLastLogin =1; + int getDeviceLastLogin = 1; Future onLoginPressed() async { try { @@ -297,12 +297,7 @@ class AuthenticationViewModel extends ChangeNotifier { } else if (apiResponse.messageStatus == 1) { if (apiResponse.data['isSMSSent']) { _appState.setAppAuthToken = apiResponse.data['LogInTokenID']; - await sendActivationCode( - otpTypeEnum: otpTypeEnum, - phoneNumber: phoneNumberController.text, - nationalIdOrFileNumber: nationalIdController.text, - ); - + await sendActivationCode(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumberController.text, nationalIdOrFileNumber: nationalIdController.text, isForRegister: false); } else { if (apiResponse.data['IsAuthenticated']) { await checkActivationCode( @@ -310,7 +305,6 @@ class AuthenticationViewModel extends ChangeNotifier { onWrongActivationCode: (String? message) {}, activationCode: null, //todo silent login case halded on the repo itself.. ); - } } } @@ -318,18 +312,23 @@ class AuthenticationViewModel extends ChangeNotifier { ); } - Future sendActivationCode({required OTPTypeEnum otpTypeEnum, required String nationalIdOrFileNumber, required String phoneNumber, dynamic payload}) async { + Future sendActivationCode({required OTPTypeEnum otpTypeEnum, required String nationalIdOrFileNumber, required String phoneNumber, required bool isForRegister, dynamic payload}) async { var request = RequestUtils.getCommonRequestSendActivationCode( - otpTypeEnum: otpTypeEnum, - mobileNumber: phoneNumber, - selectedLoginType: otpTypeEnum.toInt(), - zipCode: selectedCountrySignup.countryCode, - nationalId: int.parse(nationalIdOrFileNumber), - isFileNo: isPatientHasFile(request: payload), - patientId: 0, - isForRegister: checkIsUserComingForRegister(request: payload), - patientOutSA: isPatientOutsideSA(request: payload), - payload: payload); + otpTypeEnum: otpTypeEnum, + mobileNumber: phoneNumber, + selectedLoginType: otpTypeEnum.toInt(), + zipCode: selectedCountrySignup.countryCode, + nationalId: int.parse(nationalIdOrFileNumber), + isFileNo: isForRegister ? isPatientHasFile(request: payload) : false, + patientId: 0, + isForRegister: isForRegister, + patientOutSA: isForRegister + ? isPatientOutsideSA(request: payload) + : selectedCountrySignup.countryCode == CountryEnum.saudiArabia + ? false + : true, + payload: payload, + ); // TODO: GET APP SMS SIGNATURE HERE request.sMSSignature = "enKTDcqbOVd"; @@ -384,7 +383,7 @@ class AuthenticationViewModel extends ChangeNotifier { countryCode: selectedCountrySignup.countryCode, loginType: loginTypeEnum.toInt) .toJson(); - LoaderBottomSheet.showLoader(); + LoaderBottomSheet.showLoader(); bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true); if (isForRegister) { if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob; @@ -425,7 +424,6 @@ class AuthenticationViewModel extends ChangeNotifier { resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async { final activation = CheckActivationCode.fromJson(apiResponse.data as Map); - if (activation.errorCode == '699') { // Todo: Hide Loader // GifLoaderDialogUtils.hideDialog(context); @@ -434,7 +432,7 @@ class AuthenticationViewModel extends ChangeNotifier { return; } else if (activation.messageStatus == 2) { - LoaderBottomSheet.hideLoader(); + LoaderBottomSheet.hideLoader(); onWrongActivationCode(activation.errorEndUserMessage); return; } else if (_appState.getUserRegistrationPayload.isRegister == true) { @@ -443,7 +441,6 @@ class AuthenticationViewModel extends ChangeNotifier { // Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)); return; } else { - if (activation.list != null && activation.list!.isNotEmpty) { _appState.setAuthenticatedUser(activation.list!.first); } @@ -453,7 +450,7 @@ class AuthenticationViewModel extends ChangeNotifier { bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request); //updating the last login type in app state to show the fingerprint/face id option on home screen - if( _appState.getSelectDeviceByImeiRespModelElement !=null) { + if (_appState.getSelectDeviceByImeiRespModelElement != null) { _appState.getSelectDeviceByImeiRespModelElement!.logInType = loginTypeEnum.toInt; } LoaderBottomSheet.hideLoader(); @@ -551,12 +548,12 @@ class AuthenticationViewModel extends ChangeNotifier { loginTypeEnum = (_appState.deviceTypeID == 1 ? LoginTypeEnum.face : LoginTypeEnum.fingerprint); if (!_appState.isAuthenticated) { //commenting this api to check either the same flow working or not because this api does not needed further if work fine we will remove this - // await getPatientDeviceData(loginTypeEnum.toInt); + // await getPatientDeviceData(loginTypeEnum.toInt); await checkActivationCode(otpTypeEnum: OTPTypeEnum.faceIDFingerprint, activationCode: null, onWrongActivationCode: (String? message) {}); - await insertPatientIMEIData(loginTypeEnum.toInt); + await insertPatientIMEIData(loginTypeEnum.toInt); } else { // authenticated = true; - await insertPatientIMEIData(loginTypeEnum.toInt); + await insertPatientIMEIData(loginTypeEnum.toInt); } LoaderBottomSheet.hideLoader(); notifyListeners(); @@ -669,10 +666,12 @@ class AuthenticationViewModel extends ChangeNotifier { if (isPatientOutsideSA(request: response)) { print("=======OUT SA======="); sendActivationCode( - otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]), - nationalIdOrFileNumber: request["PatientIdentificationID"].toString(), - phoneNumber: request["PatientMobileNumber"].toString(), - payload: request); + otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]), + nationalIdOrFileNumber: request["PatientIdentificationID"].toString(), + phoneNumber: request["PatientMobileNumber"].toString(), + payload: request, + isForRegister: true, + ); } else { print("=======IN SA======="); chekUserNHICData(request: request); @@ -710,10 +709,12 @@ class AuthenticationViewModel extends ChangeNotifier { if (apiResponse.data is Map) { setNHICData(apiResponse.data, request); sendActivationCode( - otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]), - nationalIdOrFileNumber: request["PatientIdentificationID"].toString(), - phoneNumber: request["PatientMobileNumber"].toString(), - payload: request); + otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]), + nationalIdOrFileNumber: request["PatientIdentificationID"].toString(), + phoneNumber: request["PatientMobileNumber"].toString(), + payload: request, + isForRegister: true, + ); } }); @@ -813,33 +814,30 @@ class AuthenticationViewModel extends ChangeNotifier { log("Insert IMEI Failed"); } }); - } - Future getPatientDeviceData(int loginType) async { final resultEither = await _authenticationRepo.getPatientDeviceData( patientDeviceDataRequest: GetUserMobileDeviceData( - deviceToken: _appState.deviceToken, - deviceTypeId: _appState.getDeviceTypeID(), - patientId: _appState.getSelectDeviceByImeiRespModelElement!.patientId!, - patientType: _appState.getSelectDeviceByImeiRespModelElement!.patientType, - patientOutSa:_appState.getSelectDeviceByImeiRespModelElement!.outSa == true ?1 :0, - loginType: loginType, - languageId: _appState.getLanguageID(), - latitude: _appState.userLat, - longitude: _appState.userLong, - mobileNo:_appState.getSelectDeviceByImeiRespModelElement!.mobile! , - patientMobileNumber:int.parse(_appState.getSelectDeviceByImeiRespModelElement!.mobile!), - nationalId:_appState.getSelectDeviceByImeiRespModelElement!.identificationNo) + deviceToken: _appState.deviceToken, + deviceTypeId: _appState.getDeviceTypeID(), + patientId: _appState.getSelectDeviceByImeiRespModelElement!.patientId!, + patientType: _appState.getSelectDeviceByImeiRespModelElement!.patientType, + patientOutSa: _appState.getSelectDeviceByImeiRespModelElement!.outSa == true ? 1 : 0, + loginType: loginType, + languageId: _appState.getLanguageID(), + latitude: _appState.userLat, + longitude: _appState.userLong, + mobileNo: _appState.getSelectDeviceByImeiRespModelElement!.mobile!, + patientMobileNumber: int.parse(_appState.getSelectDeviceByImeiRespModelElement!.mobile!), + nationalId: _appState.getSelectDeviceByImeiRespModelElement!.identificationNo) .toJson()); resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async { if (apiResponse.messageStatus == 1) { - dynamic deviceInfo= apiResponse.data['List_MobileLoginInfo']; - getDeviceLastLogin = deviceInfo['LoginType']; + dynamic deviceInfo = apiResponse.data['List_MobileLoginInfo']; + getDeviceLastLogin = deviceInfo['LoginType']; } }); - } @override diff --git a/lib/widgets/loader/bottomsheet_loader.dart b/lib/widgets/loader/bottomsheet_loader.dart index 61f7f43..57dfa01 100644 --- a/lib/widgets/loader/bottomsheet_loader.dart +++ b/lib/widgets/loader/bottomsheet_loader.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; +import 'package:hmg_patient_app_new/core/api_consts.dart'; import 'package:hmg_patient_app_new/core/dependencies.dart'; +import 'package:hmg_patient_app_new/core/enums.dart'; import 'package:hmg_patient_app_new/core/utils/utils.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart'; @@ -15,7 +17,7 @@ class LoaderBottomSheet { showModalBottomSheet( context: _navService.navigatorKey.currentContext!, - isDismissible: false, + isDismissible: ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? true : false, enableDrag: false, backgroundColor: Colors.transparent, builder: (_) { From 7c8d7b67a998012f49662ac7cc92b92436eac689 Mon Sep 17 00:00:00 2001 From: aamir-csol Date: Thu, 11 Sep 2025 10:45:26 +0300 Subject: [PATCH 2/2] signup finalize --- lib/core/utils/request_utils.dart | 11 +++++++++-- .../authentication/authentication_view_model.dart | 10 ++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/core/utils/request_utils.dart b/lib/core/utils/request_utils.dart index fc9815d..00bfc94 100644 --- a/lib/core/utils/request_utils.dart +++ b/lib/core/utils/request_utils.dart @@ -65,7 +65,7 @@ class RequestUtils { required String? deviceToken, required bool patientOutSA, required String? loginTokenID, - RegistrationDataModelPayload? registeredData, + RegistrationDataModelPayload? registeredData, int? patientId, required String nationIdText, required String countryCode, @@ -85,7 +85,12 @@ class RequestUtils { request.logInTokenID = loginTokenID ?? ""; if (registeredData != null) { - request.searchType = registeredData.searchType ?? 1; + //TODO: Issue Here if Not Signup + request.searchType = registeredData.searchType != null + ? registeredData.searchType + : fileNo + ? 1 + : 2; request.patientID = registeredData.patientId ?? 0; request.patientIdentificationID = request.nationalID = (registeredData.patientIdentificationId ?? 0); request.dob = registeredData.dob; @@ -95,9 +100,11 @@ class RequestUtils { request.patientID = patientId ?? int.parse(nationIdText); request.patientIdentificationID = request.nationalID = 0; request.searchType = 2; + //TODO: Issue HEre is Not Login } else { request.patientID = 0; request.searchType = 1; + //TODO: Issue HEre is Not Login request.patientIdentificationID = request.nationalID = (nationIdText.isNotEmpty ? int.parse(nationIdText) : 0); } request.isRegister = false; diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index ed7cb60..b2464f6 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -383,7 +383,11 @@ class AuthenticationViewModel extends ChangeNotifier { ? _appState.getUserRegistrationPayload.projectOutSa == 1 ? true : false - : _appState.getSelectDeviceByImeiRespModelElement!.outSa!, + : _appState.getSelectDeviceByImeiRespModelElement != null + ? _appState.getSelectDeviceByImeiRespModelElement!.outSa! + : selectedCountrySignup == CountryEnum.saudiArabia + ? false + : true, loginTokenID: _appState.appAuthToken, registeredData: isForRegister ? _appState.getUserRegistrationPayload : null, nationIdText: nationalIdController.text, @@ -438,7 +442,7 @@ class AuthenticationViewModel extends ChangeNotifier { return; } else if (activation.messageStatus == 2) { - LoaderBottomSheet.hideLoader(); + LoaderBottomSheet.hideLoader(); onWrongActivationCode(activation.errorEndUserMessage); return; } else if (_appState.getUserRegistrationPayload.isRegister == true) { @@ -820,10 +824,8 @@ class AuthenticationViewModel extends ChangeNotifier { log("Insert IMEI Failed"); } }); - } - Future getPatientDeviceData(int loginType) async { final resultEither = await _authenticationRepo.getPatientDeviceData( patientDeviceDataRequest: GetUserMobileDeviceData(