Merge pull request 'switch user' (#221) from dev_aamir into master

Reviewed-on: https://34.17.182.140/Haroon6138/HMG_Patient_App_New/pulls/221
pull/225/head
Haroon6138 2 days ago
commit 9703e23a32

@ -249,4 +249,18 @@ class AppState {
_userSwitchPayloads.clear();
_childSwitchCounter = 0;
}
void clearChildUsersKeepSuperUser() {
// Keep the super user payload
final superUserPayload = _userSwitchPayloads['superUser'];
// Clear all payloads
_userSwitchPayloads.clear();
_childSwitchCounter = 0;
// Restore super user if it existed
if (superUserPayload != null) {
_userSwitchPayloads['superUser'] = superUserPayload;
}
}
}

@ -314,7 +314,7 @@ class AuthenticationRepoImp implements AuthenticationRepo {
requestBody['PatientIdentificationID'] = "";
requestBody.removeWhere((key, value) => ['NationalID', 'isDentalAllowedBackend', 'ForRegisteration'].contains(key));
appState.setIsChildLoggedIn = false;
appState.clearUserSwitchPayloads();
appState.clearChildUsersKeepSuperUser();
}
} else {
appState.setIsChildLoggedIn = true;

@ -641,8 +641,8 @@ class AuthenticationViewModel extends ChangeNotifier {
_appState.addUserSwitchPayload(activation.list!.first.toJson(), isSuperUser: true);
}
} else {
_appState.setSuperUserID = _appState.getAuthenticatedUser()?.patientId;
// _appState.setIsChildLoggedIn = false;
var allUsersPayload = _appState.getUserSwitchPayloads;
_appState.setSuperUserID = allUsersPayload['superUser']?['PatientID'];
activation.list!.first.isParentUser = true;
_appState.addUserSwitchPayload(activation.list!.first.toJson(), isSuperUser: true);
}

@ -319,7 +319,6 @@ class _FamilyCardsState extends State<FamilyCards> {
final profile = widget.profileViewList![index];
final isActive = (profile.responseId == appState.getAuthenticatedUser()?.patientId);
final isParentUser = appState.getAuthenticatedUser()?.isParentUser ?? false;
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);

Loading…
Cancel
Save