Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vinay: Let a user know through a popup that Permissions have been changed for them #3294

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
Prev Previous commit
Next Next commit
feat: added popup for notifying permission change
  • Loading branch information
vinayv-456 committed Mar 19, 2025
commit ebbe2e6fa7dca93d7b9e656ce490dacdf0348f71
25 changes: 24 additions & 1 deletion src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -214,6 +214,22 @@ export function Header(props) {
const openModal = () => {
setLogoutPopup(true);
};

const handlePermissionChangeAck = async() => {
// handle setting the ack true
try {
const res = await axios.put(ENDPOINTS.USER_PROFILE(userId), {
_id: userId,
isAcknowledged: true,
});
// console.log('response', res);
if (res.status === 200) {
props.getUserProfile(userId);
}
} catch (e) {
console.log('update ack', e);
}
}

const removeViewingUser = () => {
setPopup(false);
@@ -302,6 +318,7 @@ export function Header(props) {

if (location.pathname === '/login') return null;

const viewingUser = JSON.parse(window.sessionStorage.getItem('viewingUser'))
return (
<div className="header-wrapper">
<Navbar className="py-3 navbar" color="dark" dark expand="md">
@@ -561,8 +578,14 @@ export function Header(props) {
</Navbar>
{!isAuthUser && (
<PopUpBar
message={`You are currently viewing the header for ${viewingUser.firstName} ${viewingUser.lastName}`}
onClickClose={() => setPopup(prevPopup => !prevPopup)}
viewingUser={JSON.parse(window.sessionStorage.getItem('viewingUser'))}
/>
)}
{props.auth.isAuthenticated && !props.userProfile?.permissions?.isAcknowledged && (
<PopUpBar
message="Heads Up, there were permission changes made to this account"
onClickClose={() => handlePermissionChangeAck}
/>
)}
<div>
5 changes: 2 additions & 3 deletions src/components/PopUpBar/PopUpBar.jsx
Original file line number Diff line number Diff line change
@@ -2,11 +2,10 @@
import './PopUpBar.css';

function PopUpBar(props) {
const { viewingUser, onClickClose } = props;
const { firstName, lastName } = viewingUser;
const { message, onClickClose } = props;
return (
<div className="popup_container" data-testid="test-popup">
{`You are currently viewing the header for ${firstName} ${lastName}`}
{message}
<button type="button" className="close_button" onClick={onClickClose}>
X
</button>