|
|
|
|
@ -13,6 +13,7 @@ import 'package:hmg_patient_app_new/core/common_models/privilege/HMCProjectListM
|
|
|
|
|
import 'package:hmg_patient_app_new/core/common_models/privilege/PrivilegeModel.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/common_models/privilege/ProjectDetailListModel.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/common_models/privilege/VidaPlusProjectListModel.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/loading_utils.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/request_utils.dart';
|
|
|
|
|
@ -27,6 +28,7 @@ import 'package:hmg_patient_app_new/features/authentication/models/resp_models/a
|
|
|
|
|
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_activation_code_resp_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/check_user_staus_nhic_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/authentication/models/resp_models/select_device_by_imei.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/medical_file/medical_file_repo.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/authentication/login.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/authentication/saved_login_screen.dart';
|
|
|
|
|
@ -345,23 +347,33 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> sendActivationCode(
|
|
|
|
|
{required OTPTypeEnum otpTypeEnum, required String nationalIdOrFileNumber, required String phoneNumber, required bool isForRegister, dynamic payload, bool isComingFromResendOTP = false}) async {
|
|
|
|
|
{required OTPTypeEnum otpTypeEnum,
|
|
|
|
|
required String nationalIdOrFileNumber,
|
|
|
|
|
required String phoneNumber,
|
|
|
|
|
required bool isForRegister,
|
|
|
|
|
dynamic payload,
|
|
|
|
|
bool isComingFromResendOTP = false,
|
|
|
|
|
bool isExcludedUser = false,
|
|
|
|
|
bool isFormFamilyFile = false,
|
|
|
|
|
int? responseID}) async {
|
|
|
|
|
var request = RequestUtils.getCommonRequestSendActivationCode(
|
|
|
|
|
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,
|
|
|
|
|
);
|
|
|
|
|
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,
|
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
|
responseID: responseID);
|
|
|
|
|
|
|
|
|
|
// TODO: GET APP SMS SIGNATURE HERE
|
|
|
|
|
request.sMSSignature = await getSignature();
|
|
|
|
|
@ -370,7 +382,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
_appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(payload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final resultEither = await _authenticationRepo.sendActivationCodeRepo(sendActivationCodeReq: request, isRegister: checkIsUserComingForRegister(request: payload), languageID: 'er');
|
|
|
|
|
final resultEither =
|
|
|
|
|
await _authenticationRepo.sendActivationCodeRepo(sendActivationCodeReq: request, isRegister: checkIsUserComingForRegister(request: payload), languageID: 'er', isFormFamilyFile: isFormFamilyFile);
|
|
|
|
|
|
|
|
|
|
resultEither.fold(
|
|
|
|
|
(failure) async => await _errorHandlerService.handleError(failure: failure),
|
|
|
|
|
@ -385,7 +398,10 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
} else {
|
|
|
|
|
if (apiResponse.data != null && apiResponse.data['isSMSSent'] == true) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
if (!isComingFromResendOTP) navigateToOTPScreen(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber, isComingFromRegister: checkIsUserComingForRegister(request: payload), payload: payload);
|
|
|
|
|
if (!isComingFromResendOTP) {
|
|
|
|
|
navigateToOTPScreen(
|
|
|
|
|
otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber, isComingFromRegister: checkIsUserComingForRegister(request: payload), payload: payload, isExcludedUser: isExcludedUser);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// TODO: Handle isSMSSent false
|
|
|
|
|
// navigateToOTPScreen(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber);
|
|
|
|
|
@ -404,7 +420,13 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> checkActivationCode(
|
|
|
|
|
{required String? activationCode, required OTPTypeEnum otpTypeEnum, required Function(String? message) onWrongActivationCode, Function()? onResendActivation}) async {
|
|
|
|
|
{required String? activationCode,
|
|
|
|
|
required OTPTypeEnum otpTypeEnum,
|
|
|
|
|
required Function(String? message) onWrongActivationCode,
|
|
|
|
|
Function()? onResendActivation,
|
|
|
|
|
bool isExcludedUser = false,
|
|
|
|
|
dynamic requestID,
|
|
|
|
|
dynamic responseID}) async {
|
|
|
|
|
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1);
|
|
|
|
|
|
|
|
|
|
final request = RequestUtils.getCommonRequestWelcome(
|
|
|
|
|
@ -430,6 +452,13 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
//TODO: Error Here IN Zip Code.
|
|
|
|
|
loginType: loginTypeEnum.toInt)
|
|
|
|
|
.toJson();
|
|
|
|
|
|
|
|
|
|
if (isExcludedUser) {
|
|
|
|
|
request['PatientShareRequestID'] = requestID;
|
|
|
|
|
request['ResponseID'] = responseID;
|
|
|
|
|
request['Status'] = 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
|
if (isForRegister) {
|
|
|
|
|
if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob;
|
|
|
|
|
@ -465,7 +494,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(newRequest: CheckActivationCodeRegisterReq.fromJson(request), activationCode: activationCode, isRegister: false);
|
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(
|
|
|
|
|
newRequest: CheckActivationCodeRegisterReq.fromJson(request), activationCode: activationCode, isRegister: false, isExcludedUser: isExcludedUser);
|
|
|
|
|
|
|
|
|
|
resultEither.fold(
|
|
|
|
|
(failure) async => await _errorHandlerService.handleError(
|
|
|
|
|
@ -575,12 +605,13 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
_navigationService.pushAndReplace(AppRoutes.landingScreen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> navigateToOTPScreen({required OTPTypeEnum otpTypeEnum, required String phoneNumber, required bool isComingFromRegister, dynamic payload}) async {
|
|
|
|
|
Future<void> navigateToOTPScreen({required OTPTypeEnum otpTypeEnum, required String phoneNumber, required bool isComingFromRegister, dynamic payload, bool isExcludedUser = false}) async {
|
|
|
|
|
_navigationService.pushToOtpScreen(
|
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
|
checkActivationCode: (int activationCode) async {
|
|
|
|
|
await checkActivationCode(
|
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
|
onWrongActivationCode: (String? value) {
|
|
|
|
|
onWrongActivationCode(message: value);
|
|
|
|
|
|