|
|
|
|
@ -16,6 +16,7 @@ import 'package:hmg_patient_app/models/Authentication/check_user_status_req.dart
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/checkpatient_for_registration.dart';
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/register_info_response.dart';
|
|
|
|
|
import 'package:hmg_patient_app/models/Authentication/send_activation_request.dart';
|
|
|
|
|
import 'package:hmg_patient_app/new_ui/new_ext.dart';
|
|
|
|
|
import 'package:hmg_patient_app/new_ui/otp/otp_validation_bootmsheet_widget.dart';
|
|
|
|
|
import 'package:hmg_patient_app/pages/AlHabibMedicalService/health_calculator/carbs/carbs.dart';
|
|
|
|
|
import 'package:hmg_patient_app/pages/login/login-type.dart';
|
|
|
|
|
@ -46,6 +47,7 @@ import '../../models/Authentication/authenticated_user.dart';
|
|
|
|
|
import '../../models/Authentication/select_device_imei_res.dart';
|
|
|
|
|
import '../../models/InPatientServices/get_admission_info_response_model.dart';
|
|
|
|
|
import '../../models/InPatientServices/get_admission_request_info_response_model.dart';
|
|
|
|
|
import '../../new_ui/exception_widget/ExceptionBottomSheet.dart';
|
|
|
|
|
import '../../services/clinic_services/get_clinic_service.dart';
|
|
|
|
|
import '../../widgets/dialogs/alert_dialog.dart';
|
|
|
|
|
import '../../widgets/dialogs/confirm_dialog.dart';
|
|
|
|
|
@ -306,28 +308,60 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
icon: "assets/images/svg/note-edit.svg",
|
|
|
|
|
onPressed: () {
|
|
|
|
|
// bool isValid = Utils.validateIqama(nationalIDorFile.text);
|
|
|
|
|
if (nationalIDorFile == null) {
|
|
|
|
|
Utils.showErrorToast(TranslationBase.of(context).pleaseEnterNationalId);
|
|
|
|
|
if (nationalIDorFile == null || nationalIDorFile.text.isEmpty) {
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: TranslationBase.of(context).pleaseEnterNationalId,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
// Utils.showErrorToast(TranslationBase.of(context).pleaseEnterNationalId);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (selectedCountry == null) {
|
|
|
|
|
Utils.showErrorToast(TranslationBase.of(context).pleaseSelectCountry);
|
|
|
|
|
if (selectedCountry == null || selectedCountry.countryCode.isEmpty) {
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: TranslationBase.of(context).pleaseSelectCountry,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selectedDOB == null) {
|
|
|
|
|
Utils.showErrorToast(TranslationBase.of(context).pleaseSelectDOB);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: TranslationBase.of(context).pleaseSelectDOB,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!isTermsAccepted) {
|
|
|
|
|
Utils.showErrorToast(TranslationBase.of(context).pleaseAcceptTermsConditions);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: TranslationBase.of(context).pleaseAcceptTermsConditions,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (phoneController != null) {
|
|
|
|
|
phoneController.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
@ -349,7 +383,7 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
child: CustomButton(
|
|
|
|
|
text: TranslationBase.of(context).sendOTPSMS,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
int? val = Utils.onOtpBtnPressed(OTPType.sms, mobileNo);
|
|
|
|
|
int? val = Utils.onOtpBtnPressed(OTPType.sms, mobileNo, context);
|
|
|
|
|
registerUser(val);
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: CustomColors.bgRedColor,
|
|
|
|
|
@ -379,9 +413,8 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
child: CustomButton(
|
|
|
|
|
text: TranslationBase.of(context).sendOTPWHATSAPP,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, mobileNo);
|
|
|
|
|
int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, mobileNo, context);
|
|
|
|
|
registerUser(val);
|
|
|
|
|
// if (val != null) checkUserAuthentication(val);
|
|
|
|
|
},
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
borderColor: Color(0xFF2E3039),
|
|
|
|
|
@ -495,10 +528,6 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
|
|
|
|
|
void registerUser(int? value) {
|
|
|
|
|
otpType = value == 1 ? OTPType.sms : OTPType.whatsapp;
|
|
|
|
|
// OTPType.sms ? 1 : 2;
|
|
|
|
|
print("Country: ${selectedCountry.name}");
|
|
|
|
|
print("nationalId: ${nationalIDorFile.text}");
|
|
|
|
|
print("DOB: ${selectedDOB}");
|
|
|
|
|
if (value == 1) {
|
|
|
|
|
print("OTP sent successfully to ${mobileNo} using SMS");
|
|
|
|
|
} else {
|
|
|
|
|
@ -527,7 +556,7 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
authService.checkPatientForRegisteration(registrationData, languageID).then((response) => {checkUserStatus(response, registrationData, type)}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
ConfirmDialog dialog = new ConfirmDialog(
|
|
|
|
|
ConfirmDialog dialog = ConfirmDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
confirmMessage: err,
|
|
|
|
|
okText: TranslationBase.of(context).confirm,
|
|
|
|
|
@ -547,21 +576,20 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
var nRequest = request.toJson();
|
|
|
|
|
nRequest['LogInTokenID'] = response['LogInTokenID'];
|
|
|
|
|
if (response['hasFile'] == true) {
|
|
|
|
|
await ConfirmDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
confirmMessage: response['ErrorEndUserMessage'],
|
|
|
|
|
okText: TranslationBase.of(context).ok,
|
|
|
|
|
cancelText: TranslationBase.of(context).cancel,
|
|
|
|
|
okFunction: () {
|
|
|
|
|
AlertDialogBox.closeAlertDialog(context);
|
|
|
|
|
sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, nRequest);
|
|
|
|
|
setState(() {
|
|
|
|
|
isSkipRegistration = true;
|
|
|
|
|
});
|
|
|
|
|
sendActivationCode(type, "", null, isSkipRegistration);
|
|
|
|
|
},
|
|
|
|
|
cancelFunction: () {})
|
|
|
|
|
.showAlertDialog(context);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: response['ErrorEndUserMessage'],
|
|
|
|
|
showCancel: true,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
AlertDialogBox.closeAlertDialog(context);
|
|
|
|
|
sharedPref.setObject(REGISTER_DATA_FOR_LOGIIN, nRequest);
|
|
|
|
|
setState(() {
|
|
|
|
|
isSkipRegistration = true;
|
|
|
|
|
});
|
|
|
|
|
sendActivationCode(type, "", null, isSkipRegistration);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
final intl.DateFormat dateFormat = intl.DateFormat('dd/MM/yyyy');
|
|
|
|
|
nRequest['forRegister'] = true;
|
|
|
|
|
@ -614,7 +642,15 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
// Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true))),
|
|
|
|
|
sendActivationCode(type, loginToken, resultSet, isSkipRegistration);
|
|
|
|
|
} else {
|
|
|
|
|
AppToast.showErrorToast(message: result != null ? result : TranslationBase.of(context).somethingWentWrong);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: result != null ? result : TranslationBase.of(context).somethingWentWrong,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
@ -633,6 +669,8 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
request.isRegister = true;
|
|
|
|
|
request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
|
request.sMSSignature = await SMSOTP.getSignature();
|
|
|
|
|
// print(request.oTPSendType);
|
|
|
|
|
// request.oTPSendType = type;
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
if (selectedCountry.countryCode == "966" && !skipRegistration) {
|
|
|
|
|
@ -644,7 +682,7 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
request.patientIdentificationID = nationalIDorFile.text;
|
|
|
|
|
}
|
|
|
|
|
request.isHijri = isHijri ?? 0;
|
|
|
|
|
request.oTPSendType = type;
|
|
|
|
|
// request.oTPSendType = type;
|
|
|
|
|
if (skipRegistration) {
|
|
|
|
|
var req = getCommonRequest(type: type);
|
|
|
|
|
req.logInTokenID = "";
|
|
|
|
|
@ -667,24 +705,16 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
}
|
|
|
|
|
}).catchError((r) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: r.toString());
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: r.toString(),
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// sendActivationCodeForLogin(type, value['LogInTokenID'], null, false)
|
|
|
|
|
// request.loginTokenID = value['LogInTokenID'],
|
|
|
|
|
// request.dob = "",
|
|
|
|
|
// request.healthId = "",
|
|
|
|
|
// request.isHijri = 0,
|
|
|
|
|
// request.tokenID = value['LogInTokenID'],
|
|
|
|
|
// authService.sendActivationCode(request).then((result) {
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
// if (result != null && result['isSMSSent'] == true) {
|
|
|
|
|
// this.startSMSService(type);
|
|
|
|
|
// }
|
|
|
|
|
// }).catchError((r) {
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
// AppToast.showErrorToast(message: r.toString());
|
|
|
|
|
// })
|
|
|
|
|
} else {
|
|
|
|
|
if (value['IsAuthenticated']) {
|
|
|
|
|
checkActivationCode();
|
|
|
|
|
@ -693,17 +723,16 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
print(err);
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
ConfirmDialog dialog = new ConfirmDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
confirmMessage: err,
|
|
|
|
|
okText: TranslationBase.of(context).confirm,
|
|
|
|
|
cancelText: TranslationBase.of(context).cancel_nocaps,
|
|
|
|
|
okFunction: () => {
|
|
|
|
|
ConfirmDialog.closeAlertDialog(context),
|
|
|
|
|
Navigator.of(context).push(FadePage(page: RegisterNew())),
|
|
|
|
|
},
|
|
|
|
|
cancelFunction: () => {});
|
|
|
|
|
dialog.showAlertDialog(context);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: err.toString(),
|
|
|
|
|
showCancel: true,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
Navigator.of(context).push(FadePage(page: RegisterNew()));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
await this.authService.sendActivationCodeRegister(request).then((result) {
|
|
|
|
|
@ -715,7 +744,15 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
}
|
|
|
|
|
}).catchError((r) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
AppToast.showErrorToast(message: r);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: r.toString(),
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -756,10 +793,6 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
req.patientIdentificationID = nationalIDorFile.text;
|
|
|
|
|
req.nationalID = nationalIDorFile.text;
|
|
|
|
|
req.deviceToken = null;
|
|
|
|
|
// req.loginType = type;
|
|
|
|
|
// req.healthId = "";
|
|
|
|
|
// req.isHijri = isHijri ?? 0;
|
|
|
|
|
// req.dob = "";
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
dynamic result;
|
|
|
|
|
@ -769,9 +802,15 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
final activation = CheckActivationCode.fromJson(result as Map<String, dynamic>);
|
|
|
|
|
if (activation.errorCode == '699') {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
await Future.delayed(const Duration(seconds: 2));
|
|
|
|
|
AppToast.showErrorToast(message: activation.errorEndUserMessage);
|
|
|
|
|
Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin));
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: activation.errorEndUserMessage,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
await sharedPref.remove(FAMILY_FILE);
|
|
|
|
|
activation.list!.isFamily = false;
|
|
|
|
|
@ -790,9 +829,15 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
AppToast.showErrorToast(message: result, localContext: context);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: result,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
projectViewModel.analytics.loginRegistration.login_fail(error: result);
|
|
|
|
|
projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result);
|
|
|
|
|
}
|
|
|
|
|
@ -805,147 +850,33 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
);
|
|
|
|
|
// Optionally: Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew));
|
|
|
|
|
} else {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
|
AppToast.showErrorToast(message: result, localContext: context);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: result,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
// Optionally: log analytics here
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
|
print(err);
|
|
|
|
|
AppToast.showErrorToast(message: err.toString());
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: err.toString(),
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// checkActivationCode({value, type, skipRegistration}) async {
|
|
|
|
|
// // Navigator.pop(context);
|
|
|
|
|
// // GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
// var request = authService.getCommonRequest(
|
|
|
|
|
// registerd_data: null,
|
|
|
|
|
// deviceToken: DEVICE_TOKEN,
|
|
|
|
|
// mobileNumber: int.parse(mobileNo),
|
|
|
|
|
// zipCode: selectedCountry.countryCode,
|
|
|
|
|
// patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1,
|
|
|
|
|
// loginTokenID: LoginTokenID,
|
|
|
|
|
// selectedOption: type,
|
|
|
|
|
// user: SelectDeviceIMEIRES());
|
|
|
|
|
// dynamic res;
|
|
|
|
|
//
|
|
|
|
|
// request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
|
// if (selectedCountry.countryCode == "966" && !skipRegistration) {
|
|
|
|
|
// request.healthId = nHICData!.healthId!;
|
|
|
|
|
// } else {
|
|
|
|
|
// request.healthId = "";
|
|
|
|
|
// }
|
|
|
|
|
// request.isHijri = isHijri ?? 0;
|
|
|
|
|
// if (!skipRegistration) {
|
|
|
|
|
// request.nationalID = selectedCountry.countryCode == "966" ? nHICData!.idNumber : nationalIDorFile.text;
|
|
|
|
|
// request.patientIdentificationID = selectedCountry.countryCode == "966" ? nHICData!.idNumber : nationalIDorFile.text;
|
|
|
|
|
// request.isRegister = true;
|
|
|
|
|
// }
|
|
|
|
|
// if (skipRegistration) {
|
|
|
|
|
// request.patientIdentificationID = nationalIDorFile.text;
|
|
|
|
|
// request.nationalID = nationalIDorFile.text;
|
|
|
|
|
// request.deviceToken = null;
|
|
|
|
|
// request.healthId = "";
|
|
|
|
|
// request.isHijri = isHijri ?? 0;
|
|
|
|
|
// request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
|
// authService
|
|
|
|
|
// .checkActivationCode(request.toJson(), value)
|
|
|
|
|
// .then((result) async => {
|
|
|
|
|
// res = result,
|
|
|
|
|
// if (result is Map)
|
|
|
|
|
// {
|
|
|
|
|
// result = CheckActivationCode.fromJson(result as Map<String, dynamic>),
|
|
|
|
|
// if (result.errorCode == '699')
|
|
|
|
|
// {
|
|
|
|
|
// //699 block run here
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context),
|
|
|
|
|
// Future.delayed(Duration(seconds: 2), () {
|
|
|
|
|
// AppToast.showErrorToast(message: result.errorEndUserMessage);
|
|
|
|
|
// Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin));
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// sharedPref.remove(FAMILY_FILE),
|
|
|
|
|
// result.list.isFamily = false,
|
|
|
|
|
// user = result.list,
|
|
|
|
|
// sharedPref.setString(BLOOD_TYPE, result.patientBloodType ?? ""),
|
|
|
|
|
// authenticatedUserObject.user = result.list,
|
|
|
|
|
// context.read<ProjectViewModel>().setPrivilege(privilegeList: res),
|
|
|
|
|
// await sharedPref.setObject(MAIN_USER, result.list),
|
|
|
|
|
// await sharedPref.setObject(USER_PROFILE, result.list),
|
|
|
|
|
// loginTokenID = result.logInTokenID,
|
|
|
|
|
// await sharedPref.setObject(LOGIN_TOKEN_ID, result.logInTokenID),
|
|
|
|
|
// await sharedPref.setString(TOKEN, result.authenticationTokenID),
|
|
|
|
|
// checkIfUserAgreedBefore(result, context),
|
|
|
|
|
// context.read<ProjectViewModel>().analytics.loginRegistration.login_successful(),
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context),
|
|
|
|
|
// Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
// Navigator.of(context).pop();
|
|
|
|
|
// AppToast.showErrorToast(message: result, localContext: context);
|
|
|
|
|
// }),
|
|
|
|
|
// context.read<ProjectViewModel>().analytics.loginRegistration.login_fail(error: result),
|
|
|
|
|
// context.read<ProjectViewModel>().analytics.errorTracking.log('otp_verification_at_confirm_login', error: result)
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// .catchError((err) {
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
// Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
// print(err);
|
|
|
|
|
// AppToast.showErrorToast(message: err);
|
|
|
|
|
// // startSMSService(tempType);
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// authService
|
|
|
|
|
// .checkActivationCodeRegister(request.toJson(), value)
|
|
|
|
|
// .then((result) => {
|
|
|
|
|
// res = result,
|
|
|
|
|
// if (result is Map)
|
|
|
|
|
// {
|
|
|
|
|
// result = CheckActivationCode.fromJson(result as Map<String, dynamic>),
|
|
|
|
|
// Navigator.of(context).push(
|
|
|
|
|
// FadePage(page: RegisterNewStep2(nHICData, request)),
|
|
|
|
|
// )
|
|
|
|
|
//
|
|
|
|
|
// // // if(widget.isDubai ==false){
|
|
|
|
|
// // // widget.changePageViewIndex!(1),
|
|
|
|
|
// // // if(widget.isDubai ==false){
|
|
|
|
|
// //
|
|
|
|
|
// // Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)),
|
|
|
|
|
// // }
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// Navigator.of(context).pop(),
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context),
|
|
|
|
|
// Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
// AppToast.showErrorToast(message: result, localContext: context);
|
|
|
|
|
// }),
|
|
|
|
|
// // projectViewModel.analytics.loginRegistration.login_fail(error: result),
|
|
|
|
|
// // projectViewModel.analytics.errorTracking.log('otp_verification_at_confirm_login', error: result),
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// .catchError((err) {
|
|
|
|
|
// print(err);
|
|
|
|
|
// GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
// Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
// AppToast.showErrorToast(message: err);
|
|
|
|
|
// // startSMSService(tempType);
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
getCommonRequest({type}) {
|
|
|
|
|
bool fileNo = false;
|
|
|
|
|
if (nationalIDorFile.text != null && nationalIDorFile.text.isNotEmpty) {
|
|
|
|
|
@ -986,20 +917,6 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
return request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// startSMSService(type) {
|
|
|
|
|
// SMSOTP(
|
|
|
|
|
// context,
|
|
|
|
|
// type,
|
|
|
|
|
// phoneController.text,
|
|
|
|
|
// (value) {
|
|
|
|
|
// this.checkActivationCode(value: value, type: type);
|
|
|
|
|
// },
|
|
|
|
|
// () => {
|
|
|
|
|
// Navigator.pop(context),
|
|
|
|
|
// },
|
|
|
|
|
// ).displayDialog(context);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
startSMSService(type, skipRegistration) {
|
|
|
|
|
late SMSOTP smsOtp; // Declare the variable first
|
|
|
|
|
smsOtp = SMSOTP(
|
|
|
|
|
@ -1007,7 +924,7 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
type,
|
|
|
|
|
mobileNo,
|
|
|
|
|
(code) {
|
|
|
|
|
smsOtp.dispose(); // Now we can reference it
|
|
|
|
|
smsOtp.dispose();
|
|
|
|
|
checkActivationCode(value: code, type: type, skipRegistration: skipRegistration);
|
|
|
|
|
},
|
|
|
|
|
() {
|
|
|
|
|
@ -1031,12 +948,16 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
result = CheckActivationCode.fromJson(result as Map<String, dynamic>),
|
|
|
|
|
if (result.errorCode == '699')
|
|
|
|
|
{
|
|
|
|
|
//699 block run here
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context),
|
|
|
|
|
Future.delayed(Duration(seconds: 2), () {
|
|
|
|
|
AppToast.showErrorToast(message: result.errorEndUserMessage);
|
|
|
|
|
Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin));
|
|
|
|
|
})
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: result.errorEndUserMessage,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: WelcomeLogin));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@ -1058,19 +979,28 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context),
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
AppToast.showErrorToast(message: result, localContext: context);
|
|
|
|
|
}),
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: result.errorEndUserMessage,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
|
|
|
print(err);
|
|
|
|
|
AppToast.showErrorToast(message: err);
|
|
|
|
|
// startSMSService(tempType);
|
|
|
|
|
});
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: err,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1096,12 +1026,28 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
(r) => false);
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
print(err);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: err,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
print(err);
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
message: err,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
goToHome(context);
|
|
|
|
|
|