last login changes done.

merge-update-with-lab-changes
Sultan khan 7 months ago committed by haroon amjad
parent 007f17369b
commit ba6dc2ec9c

@ -735,7 +735,7 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
checkLastLoginStatus(AuthenticatedUser user, String deviceToken) async{ checkLastLoginStatus(AuthenticatedUser user, String deviceToken) async{
int lastLoginStatus = await sharedPref.getInt(LAST_LOGIN) != null ? await sharedPref.getInt(LAST_LOGIN) : 1; int lastLoginStatus = await sharedPref.getInt(LAST_LOGIN) != null ? await sharedPref.getInt(LAST_LOGIN) : 1;
if(lastLoginStatus == 1 || lastLoginStatus == 2){ if(lastLoginStatus == 1 || lastLoginStatus == 4){
showQuickLoginBottomSheet(context, user, deviceToken,false); showQuickLoginBottomSheet(context, user, deviceToken,false);
} }
@ -786,14 +786,17 @@ class _LandingPageState extends State<LandingPage> with WidgetsBindingObserver {
await sharedPref.setInt(LAST_LOGIN, lastLogin); await sharedPref.setInt(LAST_LOGIN, lastLogin);
showQuickLoginBottomSheet(context, user, deviceToken, true); showQuickLoginBottomSheet(context, user, deviceToken, true);
insertIMEI(lastLogin); insertIMEI(lastLogin, deviceToken);
} }
} }
insertIMEI(lastLogin) { insertIMEI(lastLogin, String deviceToken) async {
authService.insertDeviceImei(lastLogin).then((value) => {}).catchError((err) { authService.insertDeviceImei(lastLogin).then((value) => {}).catchError((err) {
print(err); print(err);
}); });
var data = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
await sharedPref.setInt(LAST_LOGIN, lastLogin);
authService.registeredAuthenticatedUser(data, deviceToken, 0, 0).then((res) => {});
} }
} }

@ -132,8 +132,14 @@ class _SavedLogin extends State<SavedLogin> {
CustomButton( CustomButton(
text: "${TranslationBase.of(context).loginBy} ${getType(widget.savedLoginData!.logInType!, context)}", text: "${TranslationBase.of(context).loginBy} ${getType(widget.savedLoginData!.logInType!, context)}",
onPressed: (){ onPressed: (){
loginWithFingerPrintFace(widget.savedLoginData!.logInType!, widget.savedLoginData!.iMEI!); if(widget.savedLoginData!.logInType! == 2 || widget.savedLoginData!.logInType! == 3) {
loginWithFingerPrintFace(widget.savedLoginData!
.logInType!, widget.savedLoginData!.iMEI!);
}else {
int? val = widget.savedLoginData!
.logInType!;
checkUserAuthentication(val);
}
}, },
backgroundColor:Color(0xffFEE9EA), backgroundColor:Color(0xffFEE9EA),
borderColor:Color(0xffFEE9EA), borderColor:Color(0xffFEE9EA),
@ -213,7 +219,7 @@ class _SavedLogin extends State<SavedLogin> {
onPressed: () { onPressed: () {
int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, phoneController); int? val = Utils.onOtpBtnPressed(OTPType.whatsapp, phoneController);
if (val != null) { if (val != null) {
//checkUserAuthentication(val); checkUserAuthentication(val);
} }
}, },
backgroundColor: Colors.white, backgroundColor: Colors.white,
@ -356,7 +362,7 @@ class _SavedLogin extends State<SavedLogin> {
getMobileInfo(request,int lastLogin) { getMobileInfo(request,int lastLogin) {
// GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
this.authService.getLoginInfo(request).then((result) { this.authService.getLoginInfo(request).then((result) {
GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
if (result['SMSLoginRequired'] == false) { if (result['SMSLoginRequired'] == false) {
@ -372,7 +378,7 @@ class _SavedLogin extends State<SavedLogin> {
} }
checkActivationCode(String? value, int loginType, String loginToken) async { checkActivationCode(String? value, int loginType, String? loginToken) async {
AppGlobal.context = context; AppGlobal.context = context;
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
var request = authService.getCommonRequest( var request = authService.getCommonRequest(
@ -382,34 +388,29 @@ class _SavedLogin extends State<SavedLogin> {
mobileNumber: int.parse(widget.savedLoginData.mobile!), mobileNumber: int.parse(widget.savedLoginData.mobile!),
zipCode: widget.savedLoginData.outSA == 1 ? '971' : '966', zipCode: widget.savedLoginData.outSA == 1 ? '971' : '966',
patientOutSA: widget.savedLoginData.outSA, patientOutSA: widget.savedLoginData.outSA,
loginTokenID: "", loginTokenID: loginToken ??"",
selectedOption: loginType, selectedOption: loginType,
user: widget.savedLoginData, user: widget.savedLoginData,
).toJson(); ).toJson();
dynamic res; dynamic res;
authService authService
.checkActivationCode(request, null) .checkActivationCode(request, value)
.then((result) async => { .then((result) async => {
res = result, res = result,
if (result is Map) if (result is Map)
{ {
result = CheckActivationCode.fromJson(result as Map<String, dynamic>), result = CheckActivationCode.fromJson(result as Map<String, dynamic>),
// if (result.errorCode == '699') if (result.errorCode == '699')
// { {
// //699 block run here //699 block run here
// GifLoaderDialogUtils.hideDialog(context), GifLoaderDialogUtils.hideDialog(context),
// Future.delayed(Duration(seconds: 2), () { Future.delayed(Duration(seconds: 2), () {
// AppToast.showErrorToast(message: result.errorEndUserMessage); AppToast.showErrorToast(message: result.errorEndUserMessage);
// Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: Login)); Navigator.pop(context);
// }) })
// } }
// else if (this.registerd_data != null && this.registerd_data.isRegister == true) else
// {
// widget.changePageViewIndex!(1),
// Navigator.popUntil(context, (route) => Utils.route(route, equalsTo: RegisterNew)),
// }
// else
{ {
sharedPref.remove(FAMILY_FILE), sharedPref.remove(FAMILY_FILE),
result.list.isFamily = false, result.list.isFamily = false,
@ -492,65 +493,27 @@ class _SavedLogin extends State<SavedLogin> {
// GifLoaderDialogUtils.hideDialog(context); // GifLoaderDialogUtils.hideDialog(context);
getToDoCount(); getToDoCount();
checkIfIsInPatient();
checkIfIsInPatient() {
bool isAdmitted = false; appointmentRateViewModel.getIsLastAppointmentRatedList(projectViewModel.isArabic ? 1 : 2).then((_) {
bool hasAdmissionRequest = false; GifLoaderDialogUtils.hideDialog(AppGlobal.context);
GetAdmissionInfoResponseModel getAdmissionInfoResponseModel;
GetAdmissionRequestInfoResponseModel getAdmissionRequestInfoResponseModel; if (appointmentRateViewModel.isHaveAppointmentNotRate) {
ClinicListService service = new ClinicListService(); Navigator.pushAndRemoveUntil(
service.checkIfInPatientAPI(context).then((res) { context,
if (res['MessageStatus'] == 1) { FadePage(page: RateAppointmentDoctor()),
isAdmitted = res['isAdmitted']; (route) => false,
hasAdmissionRequest = res['hasAdmissionRequests']; );
print("IS ADMITTED: $isAdmitted"); } else {
print("Has Admission Request: $hasAdmissionRequest"); Navigator.pushAndRemoveUntil(
if (isAdmitted) { context,
if (res['PatientAdmittedInformation'].length != 0) { FadePage(page: LandingPage()),
getAdmissionInfoResponseModel = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]); (route) => false,
projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']); );
projectViewModel.setInPatientAdmissionInfo(getAdmissionInfoResponseModel); }
projectViewModel.setIsPatientAdmitted(true); insertIMEI(type);
} }).catchError((error) {
} print(error);
if (hasAdmissionRequest) {
if (res['MedicalInstruction'].length != 0) {
getAdmissionRequestInfoResponseModel = GetAdmissionRequestInfoResponseModel.fromJson(res['MedicalInstruction'][0]);
// projectViewModel.setInPatientProjectID(res['MedicalInstruction'][0]['ProjectID']);
projectViewModel.setInPatientProjectID(res['MedicalInstruction'][0]['projectId']);
projectViewModel.setInPatientAdmissionRequest(getAdmissionRequestInfoResponseModel);
projectViewModel.setPatientHasAdmissionRequest(true);
}
}
} else {}
});
}();
appointmentRateViewModel
.getIsLastAppointmentRatedList(projectViewModel.isArabic ? 1 : 2)
.then((value) => {
GifLoaderDialogUtils.hideDialog(AppGlobal.context),
if (appointmentRateViewModel.isHaveAppointmentNotRate)
{
Navigator.pushAndRemoveUntil(
context,
FadePage(
page: RateAppointmentDoctor(),
),
(r) => false)
}
else
{
Navigator.pushAndRemoveUntil(
context,
FadePage(
page: LandingPage(),
),
(r) => false)
},
insertIMEI(type)
})
.catchError((err) {
print(err);
}); });
} }
@ -575,7 +538,6 @@ class _SavedLogin extends State<SavedLogin> {
}); });
} }
checkUserAuthentication(type) { checkUserAuthentication(type) {
// showLoader(true);
GifLoaderDialogUtils.showMyDialog(context); GifLoaderDialogUtils.showMyDialog(context);
var req = this.authService.getCommonRequest(type: type, var req = this.authService.getCommonRequest(type: type,
registerd_data: null, registerd_data: null,
@ -593,7 +555,6 @@ class _SavedLogin extends State<SavedLogin> {
authService authService
.checkPatientAuthentication(request) .checkPatientAuthentication(request)
.then((value) => { .then((value) => {
GifLoaderDialogUtils.hideDialog(context),
if (value['isSMSSent']) if (value['isSMSSent'])
{ {
sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']), sharedPref.setString(LOGIN_TOKEN_ID, value['LogInTokenID']),
@ -665,4 +626,31 @@ class _SavedLogin extends State<SavedLogin> {
}, },
).displayDialog(context); ).displayDialog(context);
} }
void checkIfIsInPatient() {
final service = ClinicListService();
service.checkIfInPatientAPI(context).then((res) {
if (res['MessageStatus'] != 1) return;
final isAdmitted = res['isAdmitted'] == true;
final hasAdmissionRequest = res['hasAdmissionRequests'] == true;
print("IS ADMITTED: $isAdmitted");
print("Has Admission Request: $hasAdmissionRequest");
if (isAdmitted && res['PatientAdmittedInformation']?.isNotEmpty == true) {
final info = GetAdmissionInfoResponseModel.fromJson(res['PatientAdmittedInformation'][0]);
projectViewModel.setInPatientProjectID(res['PatientAdmittedInformation'][0]['ProjectID']);
projectViewModel.setInPatientAdmissionInfo(info);
projectViewModel.setIsPatientAdmitted(true);
}
if (hasAdmissionRequest && res['MedicalInstruction']?.isNotEmpty == true) {
final reqInfo = GetAdmissionRequestInfoResponseModel.fromJson(res['MedicalInstruction'][0]);
projectViewModel.setInPatientProjectID(res['MedicalInstruction'][0]['projectId']);
projectViewModel.setInPatientAdmissionRequest(reqInfo);
projectViewModel.setPatientHasAdmissionRequest(true);
}
});
}
} }
Loading…
Cancel
Save