|
|
|
@ -15,6 +15,7 @@ import 'package:hmg_patient_app_new/core/utils/loading_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/request_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/request_utils.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/core/utils/validation_utils.dart';
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/validation_utils.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/context_extensions.dart';
|
|
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/authentication/authentication_repo.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_activation_code_register_request_model.dart';
|
|
|
|
import 'package:hmg_patient_app_new/features/authentication/models/request_models/check_activation_code_register_request_model.dart';
|
|
|
|
@ -31,6 +32,7 @@ import 'package:hmg_patient_app_new/services/error_handler_service.dart';
|
|
|
|
import 'package:hmg_patient_app_new/services/localauth_service.dart';
|
|
|
|
import 'package:hmg_patient_app_new/services/localauth_service.dart';
|
|
|
|
import 'package:hmg_patient_app_new/services/navigation_service.dart';
|
|
|
|
import 'package:hmg_patient_app_new/services/navigation_service.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
|
|
|
|
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
|
|
|
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/bottomsheet/exception_bottom_sheet.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import 'models/request_models/get_user_mobile_device_data.dart';
|
|
|
|
import 'models/request_models/get_user_mobile_device_data.dart';
|
|
|
|
import 'models/request_models/insert_patient_mobile_deviceinfo.dart';
|
|
|
|
import 'models/request_models/insert_patient_mobile_deviceinfo.dart';
|
|
|
|
@ -110,6 +112,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
isTermsAccepted = false;
|
|
|
|
isTermsAccepted = false;
|
|
|
|
selectedCountrySignup = CountryEnum.saudiArabia;
|
|
|
|
selectedCountrySignup = CountryEnum.saudiArabia;
|
|
|
|
pickedCountryByUAEUser = null;
|
|
|
|
pickedCountryByUAEUser = null;
|
|
|
|
|
|
|
|
_appState.setUserRegistrationPayload = RegistrationDataModelPayload();
|
|
|
|
|
|
|
|
_appState.setNHICUserData = CheckUserStatusResponseNHIC();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void onCountryChange(CountryEnum country) {
|
|
|
|
void onCountryChange(CountryEnum country) {
|
|
|
|
@ -315,40 +319,27 @@ 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, dynamic payload}) async {
|
|
|
|
bool isForRegister = checkIsUserComingForRegister(request: payload);
|
|
|
|
|
|
|
|
bool isPatientOutSA = isPatientOutsideSA(request: payload);
|
|
|
|
|
|
|
|
bool isFileNo = isPatientHasFile(request: payload);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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: isFileNo,
|
|
|
|
isFileNo: isPatientHasFile(request: payload),
|
|
|
|
patientId: 0,
|
|
|
|
patientId: 0,
|
|
|
|
isForRegister: isForRegister,
|
|
|
|
isForRegister: checkIsUserComingForRegister(request: payload),
|
|
|
|
patientOutSA: isPatientOutSA,
|
|
|
|
patientOutSA: isPatientOutsideSA(request: payload),
|
|
|
|
payload: payload);
|
|
|
|
payload: payload);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: GET APP SMS SIGNATURE HERE
|
|
|
|
// TODO: GET APP SMS SIGNATURE HERE
|
|
|
|
request.sMSSignature = "enKTDcqbOVd";
|
|
|
|
request.sMSSignature = "enKTDcqbOVd";
|
|
|
|
// GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bool isForRegister = healthId != null || isDubai;
|
|
|
|
if (checkIsUserComingForRegister(request: payload)) {
|
|
|
|
// if (isForRegister) {
|
|
|
|
_appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(payload);
|
|
|
|
// if (!isDubai) {
|
|
|
|
print("====== Demo ==========");
|
|
|
|
// request.dob = dob; //isHijri == 1 ? dob : dateFormat2.format(dateFormat.parse(dob));
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
// request.healthId = healthId;
|
|
|
|
|
|
|
|
// request.isHijri = calenderType.toInt;
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// // request.dob = "";
|
|
|
|
|
|
|
|
// // request.healthId = "";
|
|
|
|
|
|
|
|
// // request.isHijri = 0;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final resultEither = await _authenticationRepo.sendActivationCodeRepo(sendActivationCodeReq: request, isRegister: isForRegister, languageID: 'er');
|
|
|
|
final resultEither = await _authenticationRepo.sendActivationCodeRepo(sendActivationCodeReq: request, isRegister: checkIsUserComingForRegister(request: payload), languageID: 'er');
|
|
|
|
|
|
|
|
|
|
|
|
resultEither.fold(
|
|
|
|
resultEither.fold(
|
|
|
|
(failure) async => await _errorHandlerService.handleError(failure: failure),
|
|
|
|
(failure) async => await _errorHandlerService.handleError(failure: failure),
|
|
|
|
@ -386,9 +377,9 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
phoneNumber: phoneNumberController.text,
|
|
|
|
phoneNumber: phoneNumberController.text,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
deviceToken: _appState.deviceToken,
|
|
|
|
deviceToken: _appState.deviceToken,
|
|
|
|
patientOutSA: true,
|
|
|
|
patientOutSA: _appState.getUserRegistrationPayload.projectOutSa == 1 ? true : false,
|
|
|
|
loginTokenID: _appState.appAuthToken,
|
|
|
|
loginTokenID: _appState.appAuthToken,
|
|
|
|
registeredData: null,
|
|
|
|
registeredData: _appState.getUserRegistrationPayload,
|
|
|
|
nationIdText: nationalIdController.text,
|
|
|
|
nationIdText: nationalIdController.text,
|
|
|
|
countryCode: selectedCountrySignup.countryCode,
|
|
|
|
countryCode: selectedCountrySignup.countryCode,
|
|
|
|
loginType: loginTypeEnum.toInt)
|
|
|
|
loginType: loginTypeEnum.toInt)
|
|
|
|
@ -396,9 +387,19 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
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 == true) request['DOB'] = _appState.getUserRegistrationPayload.dob;
|
|
|
|
if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob;
|
|
|
|
request['HealthId'] = _appState.getUserRegistrationPayload.healthId;
|
|
|
|
request['HealthId'] = _appState.getUserRegistrationPayload.healthId;
|
|
|
|
request['IsHijri'] = _appState.getUserRegistrationPayload.isHijri;
|
|
|
|
request['IsHijri'] = _appState.getUserRegistrationPayload.isHijri;
|
|
|
|
|
|
|
|
request["PatientOutSA"] = _appState.getUserRegistrationPayload.projectOutSa == true ? 1 : 0;
|
|
|
|
|
|
|
|
request["ForRegisteration"] = _appState.getUserRegistrationPayload.isRegister;
|
|
|
|
|
|
|
|
request["isRegister"] = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (request.containsKey("OTP_SendType")) {
|
|
|
|
|
|
|
|
// request.remove("OTP_SendType");
|
|
|
|
|
|
|
|
// print("====== Demo: Removed OTP_SendType for Register state");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("====== Req");
|
|
|
|
|
|
|
|
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(newRequest: request, activationCode: activationCode.toString(), isRegister: true);
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(newRequest: request, activationCode: activationCode.toString(), isRegister: true);
|
|
|
|
|
|
|
|
|
|
|
|
@ -615,35 +616,61 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> onRegistrationComplete() async {
|
|
|
|
Future<void> onRegistrationComplete() async {
|
|
|
|
// if (emailAddress.text.isEmpty) {
|
|
|
|
var request = RequestUtils.getUserSignupCompletionRequest(fullName: nameController.text, emailAddress: emailController.text, gender: genderType, maritalStatus: maritalStatus);
|
|
|
|
// Utils.showErrorToast(TranslationBase.of(context).enterEmailAddress);
|
|
|
|
//
|
|
|
|
// return;
|
|
|
|
print("============= Final Payload ===============");
|
|
|
|
// } else {
|
|
|
|
print(request);
|
|
|
|
// Navigator.of(context).pop();
|
|
|
|
print("=================== ====================");
|
|
|
|
// registerNow();
|
|
|
|
|
|
|
|
// }
|
|
|
|
final resultEither = await _authenticationRepo.registerUser(registrationPayloadDataModelRequest: request);
|
|
|
|
//authVM!.clearDefaultInputValues();
|
|
|
|
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
|
|
|
|
|
|
|
|
if (apiResponse.data is String) {
|
|
|
|
|
|
|
|
//TODO: Here We Need to Show a Dialog Of Something in the case of Fail With OK and Cancel and the Display Variable WIll be result.
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
print(apiResponse.data as Map<String, dynamic>);
|
|
|
|
|
|
|
|
if (apiResponse.data["MessageStatus"] == 1) {
|
|
|
|
|
|
|
|
//TODO: Here We Need to Show a Dialog Of Something in the case of Success.
|
|
|
|
|
|
|
|
clearDefaultInputValues(); // This will Clear All Default Values Of User.
|
|
|
|
|
|
|
|
_navigationService.pushAndReplace(AppRoutes.loginScreen);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> checkUserStatusForRegistration({required dynamic response, required dynamic request}) async {
|
|
|
|
Future<void> checkUserStatusForRegistration({required dynamic response, required dynamic request}) async {
|
|
|
|
if (response is Map) {
|
|
|
|
if (response is Map) {
|
|
|
|
_appState.setAppAuthToken = response["LogInTokenID"];
|
|
|
|
|
|
|
|
if (response["MessageStatus"] == 2) {
|
|
|
|
if (response["MessageStatus"] == 2) {
|
|
|
|
print(response["ErrorEndUserMessage"]);
|
|
|
|
print(response["ErrorEndUserMessage"]);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (response['hasFile'] == true) {
|
|
|
|
if (response['hasFile'] == true) {
|
|
|
|
//TODO: Show Here Ok And Cancel Dialog and On OKPress it will go for sendActivationCode
|
|
|
|
//TODO: Show Here Ok And Cancel Dialog and On OKPress it will go for sendActivationCode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_navigationService.context?.showBottomSheet(
|
|
|
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
|
|
|
message: response["ErrorMessage"],
|
|
|
|
|
|
|
|
showCancel: true,
|
|
|
|
|
|
|
|
showOKButton: true,
|
|
|
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
|
|
|
_navigationService.popUntilNamed(AppRoutes.loginScreen);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onCancelPressed: () {
|
|
|
|
|
|
|
|
_navigationService.pop();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
request['forRegister'] = true;
|
|
|
|
request['forRegister'] = true;
|
|
|
|
request['isRegister'] = true;
|
|
|
|
request['isRegister'] = true;
|
|
|
|
|
|
|
|
_appState.setAppAuthToken = response['LogInTokenID'];
|
|
|
|
if (isPatientOutsideSA(request: response)) {
|
|
|
|
if (isPatientOutsideSA(request: response)) {
|
|
|
|
print("=======OUT SA=======");
|
|
|
|
print("=======OUT SA=======");
|
|
|
|
_appState.setAppAuthToken = response['LogInTokenID'];
|
|
|
|
|
|
|
|
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);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
print("=======IN SA=======");
|
|
|
|
print("=======IN SA=======");
|
|
|
|
chekUserNHICData(request: request);
|
|
|
|
chekUserNHICData(request: request);
|
|
|
|
@ -657,13 +684,12 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
|
|
bool isPatientOutsideSA({required dynamic request}) {
|
|
|
|
bool isPatientOutsideSA({required dynamic request}) {
|
|
|
|
bool isOutSideSa = false;
|
|
|
|
bool isOutSideSa = false;
|
|
|
|
if (request is Map<String, dynamic> && request.containsKey("PatientOutSA")) {
|
|
|
|
if (request["PatientOutSA"] == true || request["PatientOutSA"] == 1) {
|
|
|
|
if (request["PatientOutSA"] == true) {
|
|
|
|
isOutSideSa = true;
|
|
|
|
isOutSideSa = true;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
isOutSideSa = false;
|
|
|
|
isOutSideSa = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print(isOutSideSa);
|
|
|
|
print(isOutSideSa);
|
|
|
|
return isOutSideSa;
|
|
|
|
return isOutSideSa;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|