|
|
|
@ -99,29 +99,32 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
|
|
// Login screen errors
|
|
|
|
// Login screen errors
|
|
|
|
String? _nationalIdError;
|
|
|
|
String? _nationalIdError;
|
|
|
|
|
|
|
|
|
|
|
|
String? get nationalIdError => _nationalIdError;
|
|
|
|
String? get nationalIdError => _nationalIdError;
|
|
|
|
|
|
|
|
|
|
|
|
// Phone number errors (used in multiple screens)
|
|
|
|
// Phone number errors (used in multiple screens)
|
|
|
|
String? _phoneNumberError;
|
|
|
|
String? _phoneNumberError;
|
|
|
|
|
|
|
|
|
|
|
|
String? get phoneNumberError => _phoneNumberError;
|
|
|
|
String? get phoneNumberError => _phoneNumberError;
|
|
|
|
|
|
|
|
|
|
|
|
// Registration screen errors
|
|
|
|
// Registration screen errors
|
|
|
|
String? _nameError;
|
|
|
|
String? _nameError;
|
|
|
|
|
|
|
|
|
|
|
|
String? get nameError => _nameError;
|
|
|
|
String? get nameError => _nameError;
|
|
|
|
|
|
|
|
|
|
|
|
String? _emailError;
|
|
|
|
String? _emailError;
|
|
|
|
|
|
|
|
|
|
|
|
String? get emailError => _emailError;
|
|
|
|
String? get emailError => _emailError;
|
|
|
|
|
|
|
|
|
|
|
|
String? _dobError;
|
|
|
|
String? _dobError;
|
|
|
|
|
|
|
|
|
|
|
|
String? get dobError => _dobError;
|
|
|
|
String? get dobError => _dobError;
|
|
|
|
|
|
|
|
|
|
|
|
// Check if registration form has any errors (for container border)
|
|
|
|
// Check if registration form has any errors (for container border)
|
|
|
|
bool get hasRegistrationFormError =>
|
|
|
|
bool get hasRegistrationFormError => _nationalIdError != null || _dobError != null;
|
|
|
|
_nationalIdError != null || _dobError != null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if ID and phone have errors (for family file container)
|
|
|
|
// Check if ID and phone have errors (for family file container)
|
|
|
|
bool get hasIdAndPhoneError =>
|
|
|
|
bool get hasIdAndPhoneError => _nationalIdError != null || _phoneNumberError != null;
|
|
|
|
_nationalIdError != null || _phoneNumberError != null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Additional field errors for UAE registration step 2
|
|
|
|
// Additional field errors for UAE registration step 2
|
|
|
|
String? _genderError;
|
|
|
|
String? _genderError;
|
|
|
|
@ -130,15 +133,13 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
|
|
// Getters for step 2 field errors (nameError and emailError already exist above)
|
|
|
|
// Getters for step 2 field errors (nameError and emailError already exist above)
|
|
|
|
String? get genderError => _genderError;
|
|
|
|
String? get genderError => _genderError;
|
|
|
|
|
|
|
|
|
|
|
|
String? get maritalStatusError => _maritalStatusError;
|
|
|
|
String? get maritalStatusError => _maritalStatusError;
|
|
|
|
|
|
|
|
|
|
|
|
String? get countryError => _countryError;
|
|
|
|
String? get countryError => _countryError;
|
|
|
|
|
|
|
|
|
|
|
|
// Check if registration step 2 form has any errors (for container border)
|
|
|
|
// Check if registration step 2 form has any errors (for container border)
|
|
|
|
bool get hasRegistrationStep2FormError =>
|
|
|
|
bool get hasRegistrationStep2FormError => _nameError != null || _genderError != null || _maritalStatusError != null || _countryError != null;
|
|
|
|
_nameError != null ||
|
|
|
|
|
|
|
|
_genderError != null ||
|
|
|
|
|
|
|
|
_maritalStatusError != null ||
|
|
|
|
|
|
|
|
_countryError != null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Clear all step 2 field errors
|
|
|
|
// Clear all step 2 field errors
|
|
|
|
void clearAllStep2FieldErrors() {
|
|
|
|
void clearAllStep2FieldErrors() {
|
|
|
|
@ -481,11 +482,27 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
_countryError = null;
|
|
|
|
_countryError = null;
|
|
|
|
|
|
|
|
|
|
|
|
// Step 1: Validate name (only for UAE users)
|
|
|
|
// Step 1: Validate name (only for UAE users)
|
|
|
|
|
|
|
|
// if (isUserFromUAE()) {
|
|
|
|
|
|
|
|
// if (nameController.text.trim().isEmpty) {
|
|
|
|
|
|
|
|
// _nameError = isArabic ? "الرجاء إدخال الاسم الكامل" : "Please enter full name";
|
|
|
|
|
|
|
|
// notifyListeners();
|
|
|
|
|
|
|
|
// return false; // Stop here
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
if (isUserFromUAE()) {
|
|
|
|
if (isUserFromUAE()) {
|
|
|
|
if (nameController.text.trim().isEmpty) {
|
|
|
|
// Remove extra spaces between words
|
|
|
|
|
|
|
|
final fullName = nameController.text.trim().replaceAll(RegExp(r'\s+'), ' ');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Split into words
|
|
|
|
|
|
|
|
final nameParts = fullName.split(' ');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Require at least 2 words
|
|
|
|
|
|
|
|
if (nameParts.length < 2) {
|
|
|
|
_nameError = isArabic ? "الرجاء إدخال الاسم الكامل" : "Please enter full name";
|
|
|
|
_nameError = isArabic ? "الرجاء إدخال الاسم الكامل" : "Please enter full name";
|
|
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
return false; // Stop here
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -603,7 +620,6 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
|
|
// Format for display (use Hijri)
|
|
|
|
// Format for display (use Hijri)
|
|
|
|
dobController.text = Utils.formatHijriDateToDisplay(hijriDateTimeForController.toIso8601String());
|
|
|
|
dobController.text = Utils.formatHijriDateToDisplay(hijriDateTimeForController.toIso8601String());
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Gregorian calendar mode
|
|
|
|
// Gregorian calendar mode
|
|
|
|
// Validate the date can be parsed
|
|
|
|
// Validate the date can be parsed
|
|
|
|
@ -624,7 +640,6 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
|
|
clearDobError();
|
|
|
|
clearDobError();
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
|
|
|
|
} catch (e, stackTrace) {
|
|
|
|
} catch (e, stackTrace) {
|
|
|
|
debugPrint('onDobChange: Unexpected error processing date "$date" - $e');
|
|
|
|
debugPrint('onDobChange: Unexpected error processing date "$date" - $e');
|
|
|
|
debugPrint('Stack trace: $stackTrace');
|
|
|
|
debugPrint('Stack trace: $stackTrace');
|
|
|
|
@ -768,7 +783,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
(apiResponse) {
|
|
|
|
(apiResponse) {
|
|
|
|
// LoadingUtils.hideFullScreenLoader();
|
|
|
|
// LoadingUtils.hideFullScreenLoader();
|
|
|
|
log("apiResponse: ${apiResponse.data.toString()}");
|
|
|
|
log("apiResponse: ${apiResponse.data?.toJson().toString()}");
|
|
|
|
log("messageStatus: ${apiResponse.messageStatus.toString()}");
|
|
|
|
log("messageStatus: ${apiResponse.messageStatus.toString()}");
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
onSuccess(apiResponse.data);
|
|
|
|
onSuccess(apiResponse.data);
|
|
|
|
@ -856,6 +871,9 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
nationId: nationalIdController.text,
|
|
|
|
nationId: nationalIdController.text,
|
|
|
|
isForRegister: false,
|
|
|
|
isForRegister: false,
|
|
|
|
patientOutSA: false,
|
|
|
|
patientOutSA: false,
|
|
|
|
|
|
|
|
// patientOutSA: selectedCountrySignup == CountryEnum.others
|
|
|
|
|
|
|
|
// ? false
|
|
|
|
|
|
|
|
// : (_appState.getSelectDeviceByImeiRespModelElement != null && _appState.getSelectDeviceByImeiRespModelElement!.outSa == true ? true : false),
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
patientId: 0,
|
|
|
|
patientId: 0,
|
|
|
|
zipCode: selectedCountrySignup == CountryEnum.others
|
|
|
|
zipCode: selectedCountrySignup == CountryEnum.others
|
|
|
|
@ -889,7 +907,10 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
} else if (apiResponse.messageStatus == 1) {
|
|
|
|
if (apiResponse.data['isSMSSent']) {
|
|
|
|
if (apiResponse.data['isSMSSent']) {
|
|
|
|
_appState.setAppAuthToken = apiResponse.data['LogInTokenID'];
|
|
|
|
_appState.setAppAuthToken = apiResponse.data['LogInTokenID'];
|
|
|
|
await sendActivationCode(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumberController.text, nationalIdOrFileNumber: nationalIdController.text, isForRegister: false);
|
|
|
|
print("============================");
|
|
|
|
|
|
|
|
var zipcode = getZipCode();
|
|
|
|
|
|
|
|
print("======== Zip Code =========== $zipcode ========");
|
|
|
|
|
|
|
|
await sendActivationCode(otpTypeEnum: otpTypeEnum, phoneNumber: phoneNumberController.text, nationalIdOrFileNumber: nationalIdController.text, isForRegister: false, zipCode: zipcode);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (apiResponse.data['IsAuthenticated']) {
|
|
|
|
if (apiResponse.data['IsAuthenticated']) {
|
|
|
|
await checkActivationCode(
|
|
|
|
await checkActivationCode(
|
|
|
|
@ -911,6 +932,14 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String getZipCode() {
|
|
|
|
|
|
|
|
return selectedCountrySignup == CountryEnum.others
|
|
|
|
|
|
|
|
? "0"
|
|
|
|
|
|
|
|
: (_appState.getSelectDeviceByImeiRespModelElement != null && _appState.getSelectDeviceByImeiRespModelElement!.outSa == true
|
|
|
|
|
|
|
|
? CountryEnum.unitedArabEmirates.countryCode.toString()
|
|
|
|
|
|
|
|
: selectedCountrySignup.countryCode.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future<void> sendActivationCode(
|
|
|
|
Future<void> sendActivationCode(
|
|
|
|
{required OTPTypeEnum otpTypeEnum,
|
|
|
|
{required OTPTypeEnum otpTypeEnum,
|
|
|
|
required String nationalIdOrFileNumber,
|
|
|
|
required String nationalIdOrFileNumber,
|
|
|
|
@ -921,12 +950,13 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
bool isExcludedUser = false,
|
|
|
|
bool isExcludedUser = false,
|
|
|
|
bool isFormFamilyFile = false,
|
|
|
|
bool isFormFamilyFile = false,
|
|
|
|
bool isNeedLoading = false,
|
|
|
|
bool isNeedLoading = false,
|
|
|
|
int? responseID}) async {
|
|
|
|
int? responseID,
|
|
|
|
|
|
|
|
String? zipCode}) async {
|
|
|
|
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: zipCode ?? selectedCountrySignup.countryCode,
|
|
|
|
nationalId: nationalIdOrFileNumber,
|
|
|
|
nationalId: nationalIdOrFileNumber,
|
|
|
|
isFileNo: isForRegister ? isPatientHasFile(request: payload) : false,
|
|
|
|
isFileNo: isForRegister ? isPatientHasFile(request: payload) : false,
|
|
|
|
patientId: isFormFamilyFile ? _appState.getAuthenticatedUser()!.patientId : 0,
|
|
|
|
patientId: isFormFamilyFile ? _appState.getAuthenticatedUser()!.patientId : 0,
|
|
|
|
@ -983,6 +1013,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
navigateToOTPScreen(
|
|
|
|
navigateToOTPScreen(
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
|
|
|
|
zipCode: zipCode ?? "",
|
|
|
|
isComingFromRegister: checkIsUserComingForRegister(request: payload),
|
|
|
|
isComingFromRegister: checkIsUserComingForRegister(request: payload),
|
|
|
|
payload: payload,
|
|
|
|
payload: payload,
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
@ -1308,10 +1339,12 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
bool isFormFamilyFile = false,
|
|
|
|
bool isFormFamilyFile = false,
|
|
|
|
bool isExcludedUser = false,
|
|
|
|
bool isExcludedUser = false,
|
|
|
|
int? responseID,
|
|
|
|
int? responseID,
|
|
|
|
int? patientShareRequestID}) async {
|
|
|
|
int? patientShareRequestID,
|
|
|
|
|
|
|
|
required String zipCode}) async {
|
|
|
|
_navigationService.pushToOtpScreen(
|
|
|
|
_navigationService.pushToOtpScreen(
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
phoneNumber: phoneNumber,
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
|
|
|
|
zipCode: zipCode,
|
|
|
|
checkActivationCode: (int activationCode) async {
|
|
|
|
checkActivationCode: (int activationCode) async {
|
|
|
|
await checkActivationCode(
|
|
|
|
await checkActivationCode(
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
activationCode: activationCode.toString(),
|
|
|
|
@ -1324,7 +1357,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
onResendOTPPressed: (String phoneNumber) async {
|
|
|
|
onResendOTPPressed: (String phoneNumber, String zipCode) async {
|
|
|
|
await sendActivationCode(
|
|
|
|
await sendActivationCode(
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
otpTypeEnum: otpTypeEnum,
|
|
|
|
phoneNumber: phoneNumberController.text,
|
|
|
|
phoneNumber: phoneNumberController.text,
|
|
|
|
@ -1335,7 +1368,7 @@ class AuthenticationViewModel extends ChangeNotifier {
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
isFormFamilyFile: isFormFamilyFile,
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
isExcludedUser: isExcludedUser,
|
|
|
|
responseID: responseID,
|
|
|
|
responseID: responseID,
|
|
|
|
);
|
|
|
|
zipCode: zipCode);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|