pull/29/head
aamir-csol 2 months ago
parent 335d51a04a
commit 0c58c22ea5

@ -726,7 +726,7 @@ const DEACTIVATE_ACCOUNT = 'Services/Patients.svc/REST/PatientAppleActivation_In
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; 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 // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT

@ -82,7 +82,7 @@ class AuthenticationViewModel extends ChangeNotifier {
String errorMsg = ''; String errorMsg = '';
final FocusNode myFocusNode = FocusNode(); final FocusNode myFocusNode = FocusNode();
var healthId; var healthId;
int getDeviceLastLogin =1; int getDeviceLastLogin = 1;
Future<void> onLoginPressed() async { Future<void> onLoginPressed() async {
try { try {
@ -297,12 +297,7 @@ class AuthenticationViewModel extends ChangeNotifier {
} else if (apiResponse.messageStatus == 1) { } else if (apiResponse.messageStatus == 1) {
if (apiResponse.data['isSMSSent']) { if (apiResponse.data['isSMSSent']) {
_appState.setAppAuthToken = apiResponse.data['LogInTokenID']; _appState.setAppAuthToken = apiResponse.data['LogInTokenID'];
await sendActivationCode( await sendActivationCode(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumberController.text, nationalIdOrFileNumber: nationalIdController.text, isForRegister: false);
otpTypeEnum: otpTypeEnum,
phoneNumber: phoneNumberController.text,
nationalIdOrFileNumber: nationalIdController.text,
);
} else { } else {
if (apiResponse.data['IsAuthenticated']) { if (apiResponse.data['IsAuthenticated']) {
await checkActivationCode( await checkActivationCode(
@ -310,7 +305,6 @@ class AuthenticationViewModel extends ChangeNotifier {
onWrongActivationCode: (String? message) {}, onWrongActivationCode: (String? message) {},
activationCode: null, //todo silent login case halded on the repo itself.. activationCode: null, //todo silent login case halded on the repo itself..
); );
} }
} }
} }
@ -318,18 +312,23 @@ class AuthenticationViewModel extends ChangeNotifier {
); );
} }
Future<void> sendActivationCode({required OTPTypeEnum otpTypeEnum, required String nationalIdOrFileNumber, required String phoneNumber, dynamic payload}) async { Future<void> sendActivationCode({required OTPTypeEnum otpTypeEnum, required String nationalIdOrFileNumber, required String phoneNumber, required bool isForRegister, dynamic payload}) async {
var request = RequestUtils.getCommonRequestSendActivationCode( var request = RequestUtils.getCommonRequestSendActivationCode(
otpTypeEnum: otpTypeEnum, otpTypeEnum: otpTypeEnum,
mobileNumber: phoneNumber, mobileNumber: phoneNumber,
selectedLoginType: otpTypeEnum.toInt(), selectedLoginType: otpTypeEnum.toInt(),
zipCode: selectedCountrySignup.countryCode, zipCode: selectedCountrySignup.countryCode,
nationalId: int.parse(nationalIdOrFileNumber), nationalId: int.parse(nationalIdOrFileNumber),
isFileNo: isPatientHasFile(request: payload), isFileNo: isForRegister ? isPatientHasFile(request: payload) : false,
patientId: 0, patientId: 0,
isForRegister: checkIsUserComingForRegister(request: payload), isForRegister: isForRegister,
patientOutSA: isPatientOutsideSA(request: payload), patientOutSA: isForRegister
payload: payload); ? isPatientOutsideSA(request: payload)
: selectedCountrySignup.countryCode == CountryEnum.saudiArabia
? false
: true,
payload: payload,
);
// TODO: GET APP SMS SIGNATURE HERE // TODO: GET APP SMS SIGNATURE HERE
request.sMSSignature = "enKTDcqbOVd"; request.sMSSignature = "enKTDcqbOVd";
@ -384,7 +383,7 @@ class AuthenticationViewModel extends ChangeNotifier {
countryCode: selectedCountrySignup.countryCode, countryCode: selectedCountrySignup.countryCode,
loginType: loginTypeEnum.toInt) loginType: loginTypeEnum.toInt)
.toJson(); .toJson();
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader();
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true); bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true);
if (isForRegister) { if (isForRegister) {
if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob; 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 { resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
final activation = CheckActivationCode.fromJson(apiResponse.data as Map<String, dynamic>); final activation = CheckActivationCode.fromJson(apiResponse.data as Map<String, dynamic>);
if (activation.errorCode == '699') { if (activation.errorCode == '699') {
// Todo: Hide Loader // Todo: Hide Loader
// GifLoaderDialogUtils.hideDialog(context); // GifLoaderDialogUtils.hideDialog(context);
@ -434,7 +432,7 @@ class AuthenticationViewModel extends ChangeNotifier {
return; return;
} else if (activation.messageStatus == 2) { } else if (activation.messageStatus == 2) {
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
onWrongActivationCode(activation.errorEndUserMessage); onWrongActivationCode(activation.errorEndUserMessage);
return; return;
} else if (_appState.getUserRegistrationPayload.isRegister == true) { } else if (_appState.getUserRegistrationPayload.isRegister == true) {
@ -443,7 +441,6 @@ class AuthenticationViewModel extends ChangeNotifier {
// Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)); // Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew));
return; return;
} else { } else {
if (activation.list != null && activation.list!.isNotEmpty) { if (activation.list != null && activation.list!.isNotEmpty) {
_appState.setAuthenticatedUser(activation.list!.first); _appState.setAuthenticatedUser(activation.list!.first);
} }
@ -453,7 +450,7 @@ class AuthenticationViewModel extends ChangeNotifier {
bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request); bool isUserAgreedBefore = await checkIfUserAgreedBefore(request: request);
//updating the last login type in app state to show the fingerprint/face id option on home screen //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; _appState.getSelectDeviceByImeiRespModelElement!.logInType = loginTypeEnum.toInt;
} }
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
@ -551,12 +548,12 @@ class AuthenticationViewModel extends ChangeNotifier {
loginTypeEnum = (_appState.deviceTypeID == 1 ? LoginTypeEnum.face : LoginTypeEnum.fingerprint); loginTypeEnum = (_appState.deviceTypeID == 1 ? LoginTypeEnum.face : LoginTypeEnum.fingerprint);
if (!_appState.isAuthenticated) { 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 //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 checkActivationCode(otpTypeEnum: OTPTypeEnum.faceIDFingerprint, activationCode: null, onWrongActivationCode: (String? message) {});
await insertPatientIMEIData(loginTypeEnum.toInt); await insertPatientIMEIData(loginTypeEnum.toInt);
} else { } else {
// authenticated = true; // authenticated = true;
await insertPatientIMEIData(loginTypeEnum.toInt); await insertPatientIMEIData(loginTypeEnum.toInt);
} }
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
notifyListeners(); notifyListeners();
@ -669,10 +666,12 @@ class AuthenticationViewModel extends ChangeNotifier {
if (isPatientOutsideSA(request: response)) { if (isPatientOutsideSA(request: response)) {
print("=======OUT SA======="); print("=======OUT SA=======");
sendActivationCode( sendActivationCode(
otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]), otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]),
nationalIdOrFileNumber: request["PatientIdentificationID"].toString(), nationalIdOrFileNumber: request["PatientIdentificationID"].toString(),
phoneNumber: request["PatientMobileNumber"].toString(), phoneNumber: request["PatientMobileNumber"].toString(),
payload: request); payload: request,
isForRegister: true,
);
} else { } else {
print("=======IN SA======="); print("=======IN SA=======");
chekUserNHICData(request: request); chekUserNHICData(request: request);
@ -710,10 +709,12 @@ class AuthenticationViewModel extends ChangeNotifier {
if (apiResponse.data is Map) { if (apiResponse.data is Map) {
setNHICData(apiResponse.data, request); setNHICData(apiResponse.data, request);
sendActivationCode( sendActivationCode(
otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]), otpTypeEnum: OTPTypeEnumExtension.fromInt(request["OTP_SendType"]),
nationalIdOrFileNumber: request["PatientIdentificationID"].toString(), nationalIdOrFileNumber: request["PatientIdentificationID"].toString(),
phoneNumber: request["PatientMobileNumber"].toString(), phoneNumber: request["PatientMobileNumber"].toString(),
payload: request); payload: request,
isForRegister: true,
);
} }
}); });
@ -813,33 +814,30 @@ class AuthenticationViewModel extends ChangeNotifier {
log("Insert IMEI Failed"); log("Insert IMEI Failed");
} }
}); });
} }
Future<void> getPatientDeviceData(int loginType) async { Future<void> getPatientDeviceData(int loginType) async {
final resultEither = await _authenticationRepo.getPatientDeviceData( final resultEither = await _authenticationRepo.getPatientDeviceData(
patientDeviceDataRequest: GetUserMobileDeviceData( patientDeviceDataRequest: GetUserMobileDeviceData(
deviceToken: _appState.deviceToken, deviceToken: _appState.deviceToken,
deviceTypeId: _appState.getDeviceTypeID(), deviceTypeId: _appState.getDeviceTypeID(),
patientId: _appState.getSelectDeviceByImeiRespModelElement!.patientId!, patientId: _appState.getSelectDeviceByImeiRespModelElement!.patientId!,
patientType: _appState.getSelectDeviceByImeiRespModelElement!.patientType, patientType: _appState.getSelectDeviceByImeiRespModelElement!.patientType,
patientOutSa:_appState.getSelectDeviceByImeiRespModelElement!.outSa == true ?1 :0, patientOutSa: _appState.getSelectDeviceByImeiRespModelElement!.outSa == true ? 1 : 0,
loginType: loginType, loginType: loginType,
languageId: _appState.getLanguageID(), languageId: _appState.getLanguageID(),
latitude: _appState.userLat, latitude: _appState.userLat,
longitude: _appState.userLong, longitude: _appState.userLong,
mobileNo:_appState.getSelectDeviceByImeiRespModelElement!.mobile! , mobileNo: _appState.getSelectDeviceByImeiRespModelElement!.mobile!,
patientMobileNumber:int.parse(_appState.getSelectDeviceByImeiRespModelElement!.mobile!), patientMobileNumber: int.parse(_appState.getSelectDeviceByImeiRespModelElement!.mobile!),
nationalId:_appState.getSelectDeviceByImeiRespModelElement!.identificationNo) nationalId: _appState.getSelectDeviceByImeiRespModelElement!.identificationNo)
.toJson()); .toJson());
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async { resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
if (apiResponse.messageStatus == 1) { if (apiResponse.messageStatus == 1) {
dynamic deviceInfo= apiResponse.data['List_MobileLoginInfo']; dynamic deviceInfo = apiResponse.data['List_MobileLoginInfo'];
getDeviceLastLogin = deviceInfo['LoginType']; getDeviceLastLogin = deviceInfo['LoginType'];
} }
}); });
} }
@override @override

@ -1,6 +1,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get_it/get_it.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/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/core/utils/utils.dart';
import 'package:hmg_patient_app_new/services/navigation_service.dart'; import 'package:hmg_patient_app_new/services/navigation_service.dart';
@ -15,7 +17,7 @@ class LoaderBottomSheet {
showModalBottomSheet( showModalBottomSheet(
context: _navService.navigatorKey.currentContext!, context: _navService.navigatorKey.currentContext!,
isDismissible: false, isDismissible: ApiConsts.appEnvironmentType == AppEnvironmentTypeEnum.uat ? true : false,
enableDrag: false, enableDrag: false,
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
builder: (_) { builder: (_) {

Loading…
Cancel
Save