|
|
|
|
@ -70,7 +70,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
_errorHandlerService = errorHandlerService,
|
|
|
|
|
_appState = appState,
|
|
|
|
|
_authenticationRepo = authenticationRepo,
|
|
|
|
|
_localAuthService = localAuthService;
|
|
|
|
|
_localAuthService = localAuthService {}
|
|
|
|
|
final TextEditingController nationalIdController = TextEditingController(),
|
|
|
|
|
phoneNumberController = TextEditingController(),
|
|
|
|
|
dobController = TextEditingController(),
|
|
|
|
|
@ -182,6 +182,17 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
void onPhoneNumberChange(String? phoneNumber) {
|
|
|
|
|
phoneNumberController.text = phoneNumber!;
|
|
|
|
|
|
|
|
|
|
// Real-time validation for Others country - prevent entering Saudi/UAE numbers
|
|
|
|
|
if (selectedCountrySignup == CountryEnum.others) {
|
|
|
|
|
if (phoneNumber.startsWith('00966') || phoneNumber.startsWith('00971')) {
|
|
|
|
|
// Remove the restricted prefix
|
|
|
|
|
phoneNumberController.text = phoneNumber.replaceAll(RegExp(r'^(00966|00971)'), '');
|
|
|
|
|
phoneNumberController.selection = TextSelection.fromPosition(
|
|
|
|
|
TextPosition(offset: phoneNumberController.text.length),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onTermAccepted() {
|
|
|
|
|
@ -301,9 +312,11 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
patientOutSA: false,
|
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
|
patientId: 0,
|
|
|
|
|
zipCode: _appState.getSelectDeviceByImeiRespModelElement != null && _appState.getSelectDeviceByImeiRespModelElement!.outSa == true
|
|
|
|
|
? CountryEnum.unitedArabEmirates.countryCode
|
|
|
|
|
: selectedCountrySignup.countryCode,
|
|
|
|
|
zipCode: selectedCountrySignup == CountryEnum.others
|
|
|
|
|
? "0"
|
|
|
|
|
: (_appState.getSelectDeviceByImeiRespModelElement != null && _appState.getSelectDeviceByImeiRespModelElement!.outSa == true
|
|
|
|
|
? CountryEnum.unitedArabEmirates.countryCode
|
|
|
|
|
: selectedCountrySignup.countryCode),
|
|
|
|
|
calenderType: calenderType);
|
|
|
|
|
|
|
|
|
|
final result = await _authenticationRepo.checkPatientAuthentication(checkPatientAuthenticationReq: checkPatientAuthenticationReq);
|
|
|
|
|
@ -368,7 +381,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
mobileNumber: phoneNumber,
|
|
|
|
|
selectedLoginType: otpTypeEnum.toInt(),
|
|
|
|
|
zipCode: selectedCountrySignup.countryCode,
|
|
|
|
|
nationalId: int.parse(nationalIdOrFileNumber),
|
|
|
|
|
nationalId:nationalIdOrFileNumber,
|
|
|
|
|
isFileNo: isForRegister ? isPatientHasFile(request: payload) : false,
|
|
|
|
|
patientId: isFormFamilyFile ? _appState.getAuthenticatedUser()!.patientId : 0,
|
|
|
|
|
isForRegister: isForRegister,
|
|
|
|
|
@ -607,6 +620,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
activation.list!.first.isParentUser = true;
|
|
|
|
|
}
|
|
|
|
|
activation.list!.first.bloodGroup = activation.patientBlodType;
|
|
|
|
|
activation.list!.first.zipCode = selectedCountrySignup == CountryEnum.others ? '0' : selectedCountrySignup.countryCode;
|
|
|
|
|
_appState.setAuthenticatedUser(activation.list!.first);
|
|
|
|
|
_appState.setPrivilegeModelList(activation.list!.first.listPrivilege!);
|
|
|
|
|
_appState.setUserBloodGroup = activation.patientBlodType ?? "N/A";
|
|
|
|
|
@ -854,7 +868,9 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
await clearDefaultInputValues(); // This will Clear All Default Values Of User.
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
LoadingUtils.hideFullScreenLoader();
|
|
|
|
|
_navigationService.pushAndReplace(AppRoutes.loginScreen);
|
|
|
|
|
// _navigationService.pushAndReplace(AppRoutes.loginScreen);
|
|
|
|
|
_navigationService.pushAndRemoveUntil(CustomPageRoute(page: LandingNavigation()), (r) => false);
|
|
|
|
|
_navigationService.push(CustomPageRoute(page: LoginScreen()));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -948,22 +964,24 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
Future<void> insertPatientIMEIData(int loginType) async {
|
|
|
|
|
final resultEither = await _authenticationRepo.insertPatientIMEIData(
|
|
|
|
|
patientIMEIDataRequest: PatientInsertDeviceImei(
|
|
|
|
|
imei: _appState.deviceToken,
|
|
|
|
|
deviceTypeId: _appState.getDeviceTypeID(),
|
|
|
|
|
patientId: _appState.getAuthenticatedUser()!.patientId!,
|
|
|
|
|
patientIdentificationNo: _appState.getAuthenticatedUser()!.patientIdentificationNo!,
|
|
|
|
|
identificationNo: _appState.getAuthenticatedUser()!.patientIdentificationNo!,
|
|
|
|
|
firstName: _appState.getAuthenticatedUser()!.firstName!,
|
|
|
|
|
lastName: _appState.getAuthenticatedUser()!.lastName!,
|
|
|
|
|
patientTypeId: _appState.getAuthenticatedUser()!.patientType,
|
|
|
|
|
mobileNo: _appState.getAuthenticatedUser()!.mobileNumber!,
|
|
|
|
|
logInTypeId: loginType,
|
|
|
|
|
patientOutSa: _appState.getAuthenticatedUser()!.outSa!,
|
|
|
|
|
outSa: _appState.getAuthenticatedUser()!.outSa == 1 ? true : false,
|
|
|
|
|
biometricEnabled: loginType == 1 || loginType == 2 ? false : true,
|
|
|
|
|
firstNameN: _appState.getAuthenticatedUser()!.firstNameN,
|
|
|
|
|
lastNameN: _appState.getAuthenticatedUser()!.lastNameN,
|
|
|
|
|
).toJson());
|
|
|
|
|
imei: _appState.deviceToken,
|
|
|
|
|
deviceTypeId: _appState.getDeviceTypeID(),
|
|
|
|
|
patientId: _appState.getAuthenticatedUser()!.patientId!,
|
|
|
|
|
patientIdentificationNo: _appState.getAuthenticatedUser()!.patientIdentificationNo!,
|
|
|
|
|
identificationNo: _appState.getAuthenticatedUser()!.patientIdentificationNo!,
|
|
|
|
|
firstName: _appState.getAuthenticatedUser()!.firstName!,
|
|
|
|
|
lastName: _appState.getAuthenticatedUser()!.lastName!,
|
|
|
|
|
patientTypeId: _appState.getAuthenticatedUser()!.patientType,
|
|
|
|
|
mobileNo: _appState.getAuthenticatedUser()!.mobileNumber!,
|
|
|
|
|
logInTypeId: loginType,
|
|
|
|
|
patientOutSa: _appState.getAuthenticatedUser()!.outSa!,
|
|
|
|
|
outSa: _appState.getAuthenticatedUser()!.outSa == 1 ? true : false,
|
|
|
|
|
biometricEnabled: loginType == 1 || loginType == 2 ? false : true,
|
|
|
|
|
firstNameN: _appState.getAuthenticatedUser()!.firstNameN,
|
|
|
|
|
lastNameN: _appState.getAuthenticatedUser()!.lastNameN,
|
|
|
|
|
zipCode: _appState.getAuthenticatedUser()!.zipCode //selectedCountrySignup == CountryEnum.others ? '0': selectedCountrySignup.countryCode,
|
|
|
|
|
)
|
|
|
|
|
.toJson());
|
|
|
|
|
resultEither.fold((failure) async => await _errorHandlerService.handleError(failure: failure), (apiResponse) async {
|
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
|
log("Insert IMEI Success");
|
|
|
|
|
|