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), ], ),