|
|
|
|
@ -382,12 +382,16 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
_appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(payload);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final resultEither =
|
|
|
|
|
await _authenticationRepo.sendActivationCodeRepo(sendActivationCodeReq: request, isRegister: checkIsUserComingForRegister(request: payload), languageID: 'er', isFormFamilyFile: isFormFamilyFile);
|
|
|
|
|
final resultEither = await _authenticationRepo.sendActivationCodeRepo(
|
|
|
|
|
sendActivationCodeReq: request, isRegister: checkIsUserComingForRegister(request: payload), languageID: 'er', isFormFamilyFile: isFormFamilyFile);
|
|
|
|
|
|
|
|
|
|
resultEither.fold(
|
|
|
|
|
(failure) async => await _errorHandlerService.handleError(failure: failure),
|
|
|
|
|
(apiResponse) async {
|
|
|
|
|
int? patientShareRequestID = 0;
|
|
|
|
|
if (isFormFamilyFile) {
|
|
|
|
|
patientShareRequestID = apiResponse.data['PatientShareRequestID'];
|
|
|
|
|
}
|
|
|
|
|
if (apiResponse.messageStatus == 2) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
await _dialogService.showCommonBottomSheetWithoutH(
|
|
|
|
|
@ -400,7 +404,15 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
if (!isComingFromResendOTP) {
|
|
|
|
|
navigateToOTPScreen(
|
|
|
|
|
otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber, isComingFromRegister: checkIsUserComingForRegister(request: payload), payload: payload, isExcludedUser: isExcludedUser);
|
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
|
isComingFromRegister: checkIsUserComingForRegister(request: payload),
|
|
|
|
|
payload: payload,
|
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
|
responseID: responseID,
|
|
|
|
|
patientShareRequestID: patientShareRequestID,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// TODO: Handle isSMSSent false
|
|
|
|
|
@ -424,8 +436,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
required OTPTypeEnum otpTypeEnum,
|
|
|
|
|
required Function(String? message) onWrongActivationCode,
|
|
|
|
|
Function()? onResendActivation,
|
|
|
|
|
bool isExcludedUser = false,
|
|
|
|
|
dynamic requestID,
|
|
|
|
|
bool isFormFamilyFile = false,
|
|
|
|
|
dynamic patientShareRequestID,
|
|
|
|
|
dynamic responseID}) async {
|
|
|
|
|
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1);
|
|
|
|
|
|
|
|
|
|
@ -453,12 +465,6 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
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;
|
|
|
|
|
@ -468,7 +474,11 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
request["ForRegisteration"] = _appState.getUserRegistrationPayload.isRegister;
|
|
|
|
|
request["isRegister"] = false;
|
|
|
|
|
|
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(newRequest: request, activationCode: activationCode.toString(), isRegister: true);
|
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(
|
|
|
|
|
newRequest: request,
|
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
|
isRegister: true,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
|
|
|
|
|
@ -495,7 +505,12 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
final resultEither = await _authenticationRepo.checkActivationCodeRepo(
|
|
|
|
|
newRequest: CheckActivationCodeRegisterReq.fromJson(request), activationCode: activationCode, isRegister: false, isExcludedUser: isExcludedUser);
|
|
|
|
|
newRequest: CheckActivationCodeRegisterReq.fromJson(request),
|
|
|
|
|
activationCode: activationCode,
|
|
|
|
|
isRegister: false,
|
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
|
patientShareRequestID: patientShareRequestID,
|
|
|
|
|
responseID: responseID);
|
|
|
|
|
|
|
|
|
|
resultEither.fold(
|
|
|
|
|
(failure) async => await _errorHandlerService.handleError(
|
|
|
|
|
@ -509,6 +524,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
await _dialogService.showCommonBottomSheetWithoutH(message: failure.message, label: LocaleKeys.notice.tr(), onOkPressed: () {});
|
|
|
|
|
}), (apiResponse) async {
|
|
|
|
|
print("API Response Data: ${apiResponse.data}");
|
|
|
|
|
|
|
|
|
|
final activation = CheckActivationCode.fromJson(apiResponse.data as Map<String, dynamic>);
|
|
|
|
|
|
|
|
|
|
if (activation.errorCode == '699') {
|
|
|
|
|
@ -605,14 +622,25 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
_navigationService.pushAndReplace(AppRoutes.landingScreen);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> navigateToOTPScreen({required OTPTypeEnum otpTypeEnum, required String phoneNumber, required bool isComingFromRegister, dynamic payload, bool isExcludedUser = false}) async {
|
|
|
|
|
Future<void> navigateToOTPScreen(
|
|
|
|
|
{required OTPTypeEnum otpTypeEnum,
|
|
|
|
|
required String phoneNumber,
|
|
|
|
|
required bool isComingFromRegister,
|
|
|
|
|
dynamic payload,
|
|
|
|
|
bool isFormFamilyFile = false,
|
|
|
|
|
bool isExcludedUser = false,
|
|
|
|
|
int? responseID,
|
|
|
|
|
int? patientShareRequestID}) async {
|
|
|
|
|
_navigationService.pushToOtpScreen(
|
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
|
checkActivationCode: (int activationCode) async {
|
|
|
|
|
await checkActivationCode(
|
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
|
responseID: responseID,
|
|
|
|
|
patientShareRequestID: patientShareRequestID,
|
|
|
|
|
onWrongActivationCode: (String? value) {
|
|
|
|
|
onWrongActivationCode(message: value);
|
|
|
|
|
},
|
|
|
|
|
@ -620,12 +648,16 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
},
|
|
|
|
|
onResendOTPPressed: (String phoneNumber) async {
|
|
|
|
|
await sendActivationCode(
|
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
|
phoneNumber: phoneNumberController.text,
|
|
|
|
|
nationalIdOrFileNumber: nationalIdController.text,
|
|
|
|
|
isForRegister: isComingFromRegister,
|
|
|
|
|
isComingFromResendOTP: true,
|
|
|
|
|
payload: payload);
|
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
|
phoneNumber: phoneNumberController.text,
|
|
|
|
|
nationalIdOrFileNumber: nationalIdController.text,
|
|
|
|
|
isForRegister: isComingFromRegister,
|
|
|
|
|
isComingFromResendOTP: true,
|
|
|
|
|
payload: payload,
|
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
|
responseID: responseID,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|