diff --git a/lib/core/api_consts.dart b/lib/core/api_consts.dart index 5fb73a37..63d36252 100644 --- a/lib/core/api_consts.dart +++ b/lib/core/api_consts.dart @@ -4,7 +4,7 @@ import 'package:hmg_patient_app_new/core/enums.dart'; class ApiConsts { static const maxSmallScreen = 660; - static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod; + static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat; // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index eb6e1394..65f15c91 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -300,15 +300,31 @@ class AuthenticationRepoImp implements AuthenticationRepo { if (!isSwitchUser) { print("Initial Super User Payload"); appState.addUserSwitchPayload(requestBody, isSuperUser: true); + print(requestBody); } else if (isSwitchUser) { - print("Switch Into First Family File"); - appState.addUserSwitchPayload(requestBody, isSuperUser: false); - } else if (appState.getSuperUserID == responseID) { - print("Switching Back to Super User"); - // appState.addUserSwitchPayload(requestBody, isSuperUser: true); - } else if (isSwitchUser && appState.getSuperUserID == responseID) { - print("Switching Into Child User 1"); - // appState.addUserSwitchPayload(requestBody); + // User is switching profiles + if (appState.getSuperUserID == responseID) { + // Switching back to the super user account + print("Switching Back to Super User"); + appState.addUserSwitchPayload(requestBody, isSuperUser: true); + print(requestBody); + } else { + var superUserPaylod = appState.getUserSwitchPayloadByIndex(isSuperUser: true); + if (appState.getSuperUserID == null && superUserPaylod != null) { + if (superUserPaylod != null) { + // requestBody['LoginType'] = loginType; + // requestBody['PatientIdentificationID'] = ""; + // requestBody['DeviceToken'] = newRequest.deviceToken; + // requestBody.removeWhere((key, value) => ['NationalID', 'isDentalAllowedBackend', 'ProjectOutSA', 'ForRegisteration', 'PatientID'].contains(key)); + + } + print("Switch to Family Where Super User Is ${appState.getSuperUserID}"); + appState.addUserSwitchPayload(requestBody, isSuperUser: false); + print(requestBody); + } else { + print("Switching Into Family File Member"); + } + } } await apiClient.post( diff --git a/lib/presentation/my_family/widget/family_cards.dart b/lib/presentation/my_family/widget/family_cards.dart index a621168f..3f0d4a70 100644 --- a/lib/presentation/my_family/widget/family_cards.dart +++ b/lib/presentation/my_family/widget/family_cards.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:convert'; import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; @@ -79,8 +80,7 @@ class _FamilyCardsState extends State { children: [ Utils.buildSvgWithAssets(icon: AppAssets.alertSquare), SizedBox(width: 8.h), - LocaleKeys.whoCanViewMyMedicalFile.tr(context: context).toText14(color: AppColors.textColor, isUnderLine: true, weight: FontWeight.w500) - .onPress(() { + LocaleKeys.whoCanViewMyMedicalFile.tr(context: context).toText14(color: AppColors.textColor, isUnderLine: true, weight: FontWeight.w500).onPress(() { dialogService.showFamilyBottomSheetWithoutHWithChild( label: LocaleKeys.manageFiles.tr(context: context), message: "", @@ -136,18 +136,11 @@ class _FamilyCardsState extends State { ? AppColors.textGreenColor : AppColors.alertColor), SizedBox(height: 8.h), - Wrap( - alignment: WrapAlignment.start, - crossAxisAlignment: WrapCrossAlignment.start, - runAlignment: WrapAlignment.start, - spacing: 0.h, - children: [ - (profile.patientName ?? "").toText14(isBold: false, isCenter: false, maxlines: 1, weight: FontWeight.w600), - (getStatusTextByRequest( - FamilyFileEnum.values.firstWhere((e) => e.toInt == profile.status), profile.isRequestFromMySide ?? false)) - .toText12( - isBold: false, isCenter: false, maxLine: 1, fontWeight: FontWeight.w500, color: AppColors.greyTextColor), - ]), + Wrap(alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, runAlignment: WrapAlignment.start, spacing: 0.h, children: [ + (profile.patientName ?? "").toText14(isBold: false, isCenter: false, maxlines: 1, weight: FontWeight.w600), + (getStatusTextByRequest(FamilyFileEnum.values.firstWhere((e) => e.toInt == profile.status), profile.isRequestFromMySide ?? false)) + .toText12(isBold: false, isCenter: false, maxLine: 1, fontWeight: FontWeight.w500, color: AppColors.greyTextColor), + ]), SizedBox(height: 8.h), CustomChipWidget( height: 30.h, @@ -318,7 +311,11 @@ class _FamilyCardsState extends State { final profile = widget.profileViewList![index]; final isActive = (profile.responseId == appState.getAuthenticatedUser()?.patientId); final isParentUser = appState.getAuthenticatedUser()?.isParentUser ?? false; - final canSwitch = isParentUser || (!isParentUser && profile.responseId == appState.getSuperUserID); + print(jsonEncode(appState.getUserSwitchPayloads)); + final isSuperUser = appState.getUserSwitchPayloads; + // TODO: canSwitch functionality is currently disabled - set to true to allow all switches + // Original logic: final canSwitch = isParentUser || (!isParentUser && profile.responseId == appState.getSuperUserID); + final canSwitch = true; // Disabled - allows all users to switch return Container( padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 15.h), decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.r), @@ -469,10 +466,10 @@ class _FamilyCardsState extends State { alignment: WrapAlignment.start, children: [ (profile.patientName ?? "").toText14(isBold: false, isCenter: true, maxlines: 1, weight: FontWeight.w600), - SizedBox(width: 2.w,), - (getStatusTextByRequest( - FamilyFileEnum.values.firstWhere((e) => e.toInt == profile.status), profile.isRequestFromMySide ?? false)) - .toText14( + SizedBox( + width: 2.w, + ), + (getStatusTextByRequest(FamilyFileEnum.values.firstWhere((e) => e.toInt == profile.status), profile.isRequestFromMySide ?? false)).toText14( isBold: false, isCenter: true, maxlines: 1,