|
|
|
@ -344,7 +344,14 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> sendActivationCode(
|
|
|
|
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,
|
|
|
|
|
|
|
|
int? responseID}) async {
|
|
|
|
var request = RequestUtils.getCommonRequestSendActivationCode(
|
|
|
|
var request = RequestUtils.getCommonRequestSendActivationCode(
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
mobileNumber: phoneNumber,
|
|
|
|
mobileNumber: phoneNumber,
|
|
|
|
@ -360,6 +367,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
? false
|
|
|
|
? false
|
|
|
|
: true,
|
|
|
|
: true,
|
|
|
|
payload: payload,
|
|
|
|
payload: payload,
|
|
|
|
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
|
|
|
|
responseID: responseID,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: GET APP SMS SIGNATURE HERE
|
|
|
|
// TODO: GET APP SMS SIGNATURE HERE
|
|
|
|
@ -369,7 +378,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
_appState.setUserRegistrationPayload = RegistrationDataModelPayload.fromJson(payload);
|
|
|
|
_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', isExcludedUser: isExcludedUser);
|
|
|
|
|
|
|
|
|
|
|
|
resultEither.fold(
|
|
|
|
resultEither.fold(
|
|
|
|
(failure) async => await _errorHandlerService.handleError(failure: failure),
|
|
|
|
(failure) async => await _errorHandlerService.handleError(failure: failure),
|
|
|
|
@ -384,7 +394,9 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (apiResponse.data != null && apiResponse.data['isSMSSent'] == true) {
|
|
|
|
if (apiResponse.data != null && apiResponse.data['isSMSSent'] == true) {
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
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 {
|
|
|
|
} else {
|
|
|
|
// TODO: Handle isSMSSent false
|
|
|
|
// TODO: Handle isSMSSent false
|
|
|
|
// navigateToOTPScreen(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber);
|
|
|
|
// navigateToOTPScreen(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumber);
|
|
|
|
@ -403,7 +415,13 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> checkActivationCode(
|
|
|
|
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);
|
|
|
|
bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1);
|
|
|
|
|
|
|
|
|
|
|
|
final request = RequestUtils.getCommonRequestWelcome(
|
|
|
|
final request = RequestUtils.getCommonRequestWelcome(
|
|
|
|
@ -429,6 +447,13 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
//TODO: Error Here IN Zip Code.
|
|
|
|
//TODO: Error Here IN Zip Code.
|
|
|
|
loginType: loginTypeEnum.toInt)
|
|
|
|
loginType: loginTypeEnum.toInt)
|
|
|
|
.toJson();
|
|
|
|
.toJson();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isExcludedUser) {
|
|
|
|
|
|
|
|
request['PatientShareRequestID'] = requestID;
|
|
|
|
|
|
|
|
request['ResponseID'] = responseID;
|
|
|
|
|
|
|
|
request['Status'] = 3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
if (isForRegister) {
|
|
|
|
if (isForRegister) {
|
|
|
|
if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob;
|
|
|
|
if (_appState.getUserRegistrationPayload.patientOutSa == 0) request['DOB'] = _appState.getUserRegistrationPayload.dob;
|
|
|
|
@ -464,7 +489,8 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} 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(
|
|
|
|
resultEither.fold(
|
|
|
|
(failure) async => await _errorHandlerService.handleError(
|
|
|
|
(failure) async => await _errorHandlerService.handleError(
|
|
|
|
@ -573,12 +599,13 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
_navigationService.pushAndReplace(AppRoutes.landingScreen);
|
|
|
|
_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(
|
|
|
|
_navigationService.pushToOtpScreen(
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
checkActivationCode: (int activationCode) async {
|
|
|
|
checkActivationCode: (int activationCode) async {
|
|
|
|
await checkActivationCode(
|
|
|
|
await checkActivationCode(
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
onWrongActivationCode: (String? value) {
|
|
|
|
onWrongActivationCode: (String? value) {
|
|
|
|
onWrongActivationCode(message: value);
|
|
|
|
onWrongActivationCode(message: value);
|
|
|
|
|