|
|
|
@ -548,31 +548,34 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
request.isRegister = true;
|
|
|
|
request.isRegister = true;
|
|
|
|
request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
request.isHijri = isHijri ?? 0;
|
|
|
|
request.isHijri = isHijri ?? 0;
|
|
|
|
this.checkPatientForRegisteration(registrationData: request, type: type);
|
|
|
|
checkPatientForRegistration(registrationData: request, type: type);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
checkPatientForRegisteration({required CheckPatientForRegistration registrationData, type}) {
|
|
|
|
checkPatientForRegistration({required CheckPatientForRegistration registrationData, type}) {
|
|
|
|
int languageID = Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 1 : 2;
|
|
|
|
int languageID = Provider.of<ProjectViewModel>(context, listen: false).isArabic ? 1 : 2;
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
authService.checkPatientForRegisteration(registrationData, languageID).then((response) => {checkUserStatus(response, registrationData, type)}).catchError((err) {
|
|
|
|
authService.checkPatientForRegisteration(registrationData, languageID).then((response) => {
|
|
|
|
|
|
|
|
// Keep loader active, continue to next step
|
|
|
|
|
|
|
|
checkUserStatus(response, registrationData, type)
|
|
|
|
|
|
|
|
}).catchError((err) {
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
ConfirmDialog dialog = ConfirmDialog(
|
|
|
|
|
|
|
|
context: context,
|
|
|
|
context.showBottomSheet(
|
|
|
|
confirmMessage: err,
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
okText: TranslationBase.of(context).confirm,
|
|
|
|
showCancel: true,
|
|
|
|
cancelText: TranslationBase.of(context).cancel_nocaps,
|
|
|
|
message: err,
|
|
|
|
okFunction: () => {
|
|
|
|
onOkPressed: () {
|
|
|
|
ConfirmDialog.closeAlertDialog(context),
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
Navigator.of(context).push(FadePage(page: RegisterNew())),
|
|
|
|
Navigator.of(context).push(FadePage(page: RegisterNew()));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
cancelFunction: () => {ConfirmDialog.closeAlertDialog(context)});
|
|
|
|
),
|
|
|
|
dialog.showAlertDialog(context);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
checkUserStatus(response, CheckPatientForRegistration request, type) async {
|
|
|
|
checkUserStatus(response, CheckPatientForRegistration request, type) async {
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
// No loader shown here since it's already hidden in checkPatientForRegisteration
|
|
|
|
if (response is Map) {
|
|
|
|
if (response is Map) {
|
|
|
|
var nRequest = request.toJson();
|
|
|
|
var nRequest = request.toJson();
|
|
|
|
nRequest['LogInTokenID'] = response['LogInTokenID'];
|
|
|
|
nRequest['LogInTokenID'] = response['LogInTokenID'];
|
|
|
|
@ -609,20 +612,19 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// if (response['ErrorCode'] == '-986') {
|
|
|
|
// if (response['ErrorCode'] == '-986') {
|
|
|
|
//AppToast.showErrorToast(message: response);
|
|
|
|
//AppToast.showErrorToast(message: response);
|
|
|
|
AlertDialogBox(
|
|
|
|
context.showBottomSheet(
|
|
|
|
context: context,
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
confirmMessage: response,
|
|
|
|
message: response,
|
|
|
|
okText: TranslationBase.of(context).ok,
|
|
|
|
onOkPressed: () {
|
|
|
|
okFunction: () {
|
|
|
|
|
|
|
|
AlertDialogBox.closeAlertDialog(context);
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}).showAlertDialog(context);
|
|
|
|
},
|
|
|
|
//}
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
chekUserData(loginToken, int type) {
|
|
|
|
chekUserData(loginToken, int type) {
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
// Keep existing loader active, don't show new one
|
|
|
|
var request = CheckUserStatusRequest();
|
|
|
|
var request = CheckUserStatusRequest();
|
|
|
|
request.patientIdentificationID = nationalIDorFile.text;
|
|
|
|
request.patientIdentificationID = nationalIDorFile.text;
|
|
|
|
request.dOB = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
request.dOB = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
@ -630,19 +632,17 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
request.patientOutSA = selectedCountry.countryCode == '966' ? 0 : 1;
|
|
|
|
request.patientOutSA = selectedCountry.countryCode == '966' ? 0 : 1;
|
|
|
|
|
|
|
|
|
|
|
|
this.authService.checkUserStatus(request).then((result) {
|
|
|
|
this.authService.checkUserStatus(request).then((result) {
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
// Keep loader active, continue to next step
|
|
|
|
if (result is Map) {
|
|
|
|
if (result is Map) {
|
|
|
|
RegisterInfoResponse? resultSet;
|
|
|
|
RegisterInfoResponse? resultSet;
|
|
|
|
|
|
|
|
|
|
|
|
CheckUserStatusResponse res = CheckUserStatusResponse.fromJson(result as Map<String, dynamic>);
|
|
|
|
CheckUserStatusResponse res = CheckUserStatusResponse.fromJson(result as Map<String, dynamic>);
|
|
|
|
nHICData = res;
|
|
|
|
nHICData = res;
|
|
|
|
sharedPref.setObject(NHIC_DATA, res.toJson());
|
|
|
|
sharedPref.setObject(NHIC_DATA, res.toJson());
|
|
|
|
resultSet = RegisterInfoResponse.fromJson(res.toJson());
|
|
|
|
resultSet = RegisterInfoResponse.fromJson(res.toJson());
|
|
|
|
|
|
|
|
|
|
|
|
// widget.changePageViewIndex!(1),
|
|
|
|
|
|
|
|
// Navigator.of(context).push(FadePage(page: ConfirmLogin(changePageViewIndex: widget.changePageViewIndex, fromRegistration: true))),
|
|
|
|
|
|
|
|
sendActivationCode(type, loginToken, resultSet, isSkipRegistration);
|
|
|
|
sendActivationCode(type, loginToken, resultSet, isSkipRegistration);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
context.showBottomSheet(
|
|
|
|
context.showBottomSheet(
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
message: result != null ? result : TranslationBase.of(context).somethingWentWrong,
|
|
|
|
message: result != null ? result : TranslationBase.of(context).somethingWentWrong,
|
|
|
|
@ -653,6 +653,17 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catchError((err) {
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
|
|
|
context.showBottomSheet(
|
|
|
|
|
|
|
|
child: ExceptionBottomSheet(
|
|
|
|
|
|
|
|
message: err.toString(),
|
|
|
|
|
|
|
|
showCancel: false,
|
|
|
|
|
|
|
|
onOkPressed: () {
|
|
|
|
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -666,13 +677,12 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1,
|
|
|
|
patientOutSA: selectedCountry.countryCode == "966" ? 0 : 1,
|
|
|
|
loginTokenID: LoginTokenID,
|
|
|
|
loginTokenID: LoginTokenID,
|
|
|
|
selectedOption: type,
|
|
|
|
selectedOption: type,
|
|
|
|
|
|
|
|
type: type,
|
|
|
|
user: SelectDeviceIMEIRES());
|
|
|
|
user: SelectDeviceIMEIRES());
|
|
|
|
request.isRegister = true;
|
|
|
|
request.isRegister = true;
|
|
|
|
request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
request.dob = isHijri == 1 ? selectedDOB!.toString() : dateFormat.format(selectedDOB!);
|
|
|
|
request.sMSSignature = await SMSOTP.getSignature();
|
|
|
|
request.sMSSignature = await SMSOTP.getSignature();
|
|
|
|
// print(request.oTPSendType);
|
|
|
|
print("Otp Send Type =" + request.oTPSendType.toString());
|
|
|
|
// request.oTPSendType = type;
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.showMyDialog(context);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (selectedCountry.countryCode == "966" && !skipRegistration) {
|
|
|
|
if (selectedCountry.countryCode == "966" && !skipRegistration) {
|
|
|
|
request.healthId = nHICData!.healthId;
|
|
|
|
request.healthId = nHICData!.healthId;
|
|
|
|
@ -683,11 +693,13 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
request.patientIdentificationID = nationalIDorFile.text;
|
|
|
|
request.patientIdentificationID = nationalIDorFile.text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
request.isHijri = isHijri ?? 0;
|
|
|
|
request.isHijri = isHijri ?? 0;
|
|
|
|
// request.oTPSendType = type;
|
|
|
|
|
|
|
|
if (skipRegistration) {
|
|
|
|
if (skipRegistration) {
|
|
|
|
|
|
|
|
// Keep existing loader active, don't show new one
|
|
|
|
var req = getCommonRequest(type: type);
|
|
|
|
var req = getCommonRequest(type: type);
|
|
|
|
req.logInTokenID = "";
|
|
|
|
req.logInTokenID = "";
|
|
|
|
var request = CheckPatientAuthenticationReq.fromJson(req.toJson());
|
|
|
|
var request = CheckPatientAuthenticationReq.fromJson(req.toJson());
|
|
|
|
|
|
|
|
|
|
|
|
authService.checkPatientAuthentication(request).then((value) async {
|
|
|
|
authService.checkPatientAuthentication(request).then((value) async {
|
|
|
|
if (value['isSMSSent']) {
|
|
|
|
if (value['isSMSSent']) {
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']);
|
|
|
|
sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']);
|
|
|
|
@ -700,6 +712,7 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
request.isHijri = 0;
|
|
|
|
request.isHijri = 0;
|
|
|
|
|
|
|
|
|
|
|
|
await authService.sendActivationCode(request).then((result) {
|
|
|
|
await authService.sendActivationCode(request).then((result) {
|
|
|
|
|
|
|
|
// Hide loader before navigation to SMS OTP
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
if (result != null && result['isSMSSent'] == true) {
|
|
|
|
if (result != null && result['isSMSSent'] == true) {
|
|
|
|
startSMSService(request.loginType, skipRegistration);
|
|
|
|
startSMSService(request.loginType, skipRegistration);
|
|
|
|
@ -718,7 +731,12 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (value['IsAuthenticated']) {
|
|
|
|
if (value['IsAuthenticated']) {
|
|
|
|
checkActivationCode(onWrongActivationCode: (String? message, bool? isReroute) {});
|
|
|
|
// Keep loader active and proceed to checkActivationCode
|
|
|
|
|
|
|
|
checkActivationCode(onWrongActivationCode: (String? message, bool? isReroute) {
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catchError((err) {
|
|
|
|
}).catchError((err) {
|
|
|
|
@ -736,11 +754,12 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// Keep existing loader active, don't show new one
|
|
|
|
await this.authService.sendActivationCodeRegister(request).then((result) {
|
|
|
|
await this.authService.sendActivationCodeRegister(request).then((result) {
|
|
|
|
|
|
|
|
// Hide loader before navigation to SMS OTP
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
if (result != null && result['isSMSSent'] == true) {
|
|
|
|
if (result != null && result['isSMSSent'] == true) {
|
|
|
|
print(result);
|
|
|
|
print(result);
|
|
|
|
// LoginTokenID = result["LogInTokenID"];
|
|
|
|
|
|
|
|
startSMSService(type, skipRegistration);
|
|
|
|
startSMSService(type, skipRegistration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catchError((r) {
|
|
|
|
}).catchError((r) {
|
|
|
|
@ -840,6 +859,7 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
result = await authService.checkActivationCodeRegister(req.toJson(), value);
|
|
|
|
result = await authService.checkActivationCodeRegister(req.toJson(), value);
|
|
|
|
if (result is Map) {
|
|
|
|
if (result is Map) {
|
|
|
|
final activation = CheckActivationCode.fromJson(result as Map<String, dynamic>);
|
|
|
|
final activation = CheckActivationCode.fromJson(result as Map<String, dynamic>);
|
|
|
|
|
|
|
|
GifLoaderDialogUtils.hideDialog(context);
|
|
|
|
Navigator.of(context).push(
|
|
|
|
Navigator.of(context).push(
|
|
|
|
FadePage(page: RegisterNewStep2(nHICData, req)),
|
|
|
|
FadePage(page: RegisterNewStep2(nHICData, req)),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
@ -916,6 +936,7 @@ class _RegisterNew extends State<RegisterNew> {
|
|
|
|
|
|
|
|
|
|
|
|
startSMSService(type, skipRegistration) {
|
|
|
|
startSMSService(type, skipRegistration) {
|
|
|
|
late SMSOTP smsOtp;
|
|
|
|
late SMSOTP smsOtp;
|
|
|
|
|
|
|
|
|
|
|
|
smsOtp = SMSOTP(
|
|
|
|
smsOtp = SMSOTP(
|
|
|
|
context,
|
|
|
|
context,
|
|
|
|
type,
|
|
|
|
type,
|
|
|
|
|