From 3acd549de7ba1c42a37332914a5448e6cb4a055d Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Wed, 24 Sep 2025 15:07:36 +0300 Subject: [PATCH 1/2] no message --- .../medical_file/medical_file_view_model.dart | 40 ++++--------------- lib/presentation/my_family/my_Family.dart | 5 ++- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/lib/features/medical_file/medical_file_view_model.dart b/lib/features/medical_file/medical_file_view_model.dart index 1c3d353..cb21b90 100644 --- a/lib/features/medical_file/medical_file_view_model.dart +++ b/lib/features/medical_file/medical_file_view_model.dart @@ -45,7 +45,7 @@ class MedicalFileViewModel extends ChangeNotifier { int selectedMedicalReportsTabIndex = 0; static final DialogService _dialogService = getIt.get(); AppState _appState = getIt(); - + AuthenticationViewModel authVM = getIt.get(); MedicalFileViewModel({required this.medicalFileRepo, required this.errorHandlerService}); initMedicalFileProvider() { @@ -267,41 +267,15 @@ class MedicalFileViewModel extends ChangeNotifier { ); } - Future switchFamilyFiles({Function(dynamic)? onSuccess, Function(String)? onError}) async { - final result = await medicalFileRepo.getPatientFamilyFiles(); + Future switchFamilyFiles( {Function(dynamic)? onSuccess,int? responseID,int? patientID, String? phoneNumber, Function(String)? onError}) async { + authVM.phoneNumberController.text = phoneNumber!; + + await authVM.checkActivationCode(activationCode: '0000', otpTypeEnum: OTPTypeEnum.sms, onWrongActivationCode: (String? str) {}, responseID: responseID, requestID: patientID, isExcludedUser: true); - result.fold( - (failure) async => await errorHandlerService.handleError( - failure: failure, - onOkPressed: () { - onError!(failure.message); - }, - ), - (apiResponse) { - if (apiResponse.messageStatus == 2) { - _dialogService.showErrorBottomSheet(message: apiResponse.errorMessage!, onOkPressed: () {}); - } else if (apiResponse.messageStatus == 1) { - patientFamilyFiles = apiResponse.data!; - patientFamilyFiles.insert( - 0, - FamilyFileResponseModelLists( - patientId: _appState.getAuthenticatedUser()!.patientId, - patientName: '${_appState.getAuthenticatedUser()!.firstName!} ${_appState.getAuthenticatedUser()!.lastName!}', - isActive: true, - gender: _appState.getAuthenticatedUser()!.gender!, - responseId: _appState.getAuthenticatedUser()!.patientId), - ); - notifyListeners(); - if (onSuccess != null) { - onSuccess(apiResponse); - } - } - }, - ); - } + } Future addFamilyFile({required OTPTypeEnum otpTypeEnum, required bool isExcludedUser}) async { - AuthenticationViewModel authVM = getIt.get(); + NavigationService navigationService = getIt.get(); FamilyFileRequest request = await RequestUtils.getAddFamilyRequest(nationalIDorFile: authVM.nationalIdController.text, mobileNo: authVM.phoneNumberController.text, countryCode: authVM.selectedCountrySignup.countryCode); diff --git a/lib/presentation/my_family/my_Family.dart b/lib/presentation/my_family/my_Family.dart index 7ebd069..25fe55c 100644 --- a/lib/presentation/my_family/my_Family.dart +++ b/lib/presentation/my_family/my_Family.dart @@ -70,7 +70,10 @@ class _FamilyMedicalScreenState extends State { onTabChange: (int index) {}, ), SizedBox(height: 25.h), - FamilyCards(profiles: widget.profiles, onSelect: widget.onSelect, isShowDetails: true), + FamilyCards(profiles: widget.profiles, onSelect: (FamilyFileResponseModelLists profile){ + medicalVM?.switchFamilyFiles(responseID: profile.responseId, patientID: profile.patientId, phoneNumber: profile.mobileNumber); + + }, isShowDetails: true), SizedBox(height: 20.h), ], ), From e2188b5a6931b38961d1aa1aeff89ae76c588e1f Mon Sep 17 00:00:00 2001 From: Sultan khan Date: Thu, 25 Sep 2025 15:24:15 +0300 Subject: [PATCH 2/2] switch family member with super user --- .../authentication/authentication_repo.dart | 16 +++++++++++++--- .../authentication_view_model.dart | 8 +++++--- .../medical_file/medical_file_view_model.dart | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 7fe9297..2ed43d8 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -28,7 +28,9 @@ abstract class AuthenticationRepo { int? patientShareRequestID, int? responseID, bool isSwitchUser = false, - int? patientID}); + int? patientID, + int? loginType + }); Future>> checkIfUserAgreed({required dynamic commonAuthanticatedRequest}); @@ -192,6 +194,7 @@ class AuthenticationRepoImp implements AuthenticationRepo { int? responseID, bool isSwitchUser = false, int? patientID, + int? loginType }) async { if (isRegister) { newRequest["activationCode"] = activationCode ?? "0000"; @@ -215,12 +218,19 @@ class AuthenticationRepoImp implements AuthenticationRepo { Map switchRequest = {}; if (isSwitchUser) { switchRequest = newRequest.toJson(); - switchRequest['SuperUser'] = patientID; + switchRequest['PatientID'] = responseID; switchRequest['IsSilentLogin'] = true; switchRequest['LogInTokenID'] = null; - switchRequest['DeviceToken'] = null; switchRequest['SearchType'] = 2; + if(loginType != 0) { + switchRequest['SuperUser'] = patientID; + switchRequest['DeviceToken'] = null; + }else{ + switchRequest['LoginType'] = 2; + } + + } final endpoint = isFormFamilyFile diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index d42c8cf..8cb5eed 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -247,7 +247,7 @@ class AuthenticationViewModel extends ChangeNotifier { await selectDeviceImei(onSuccess: (dynamic respData) async { try { if (respData != null) { - dynamic data = SelectDeviceByImeiRespModelElement.fromJson(respData.toJson()); + dynamic data = await SelectDeviceByImeiRespModelElement.fromJson(respData.toJson()); _appState.setSelectDeviceByImeiRespModelElement(data); LoaderBottomSheet.hideLoader(); @@ -440,7 +440,8 @@ class AuthenticationViewModel extends ChangeNotifier { dynamic patientShareRequestID, dynamic responseID, bool isSwitchUser =false, - int? patientID + int? patientID, + }) async { bool isForRegister = (_appState.getUserRegistrationPayload.healthId != null || _appState.getUserRegistrationPayload.patientOutSa == true || _appState.getUserRegistrationPayload.patientOutSa == 1); @@ -515,7 +516,8 @@ class AuthenticationViewModel extends ChangeNotifier { patientShareRequestID: patientShareRequestID, responseID: responseID, isSwitchUser: isSwitchUser, - patientID: patientID + patientID: patientID, + loginType: _appState.superUserID != null ? 0 : 2, ); resultEither.fold( diff --git a/lib/features/medical_file/medical_file_view_model.dart b/lib/features/medical_file/medical_file_view_model.dart index 51836a6..aa77700 100644 --- a/lib/features/medical_file/medical_file_view_model.dart +++ b/lib/features/medical_file/medical_file_view_model.dart @@ -275,7 +275,9 @@ class MedicalFileViewModel extends ChangeNotifier { ? phoneNumber.replaceFirst("0", "") : phoneNumber; - await authVM.checkActivationCode(activationCode: '0000', otpTypeEnum: OTPTypeEnum.sms, onWrongActivationCode: (String? str) {}, responseID: responseID, isFormFamilyFile:false, isSwitchUser: true, patientID: patientID); + + + await authVM.checkActivationCode(activationCode: '0000', otpTypeEnum: OTPTypeEnum.sms, onWrongActivationCode: (String? str) {}, responseID: responseID, isFormFamilyFile:false, isSwitchUser: true, patientID: patientID, ); }