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

Fix signinout issue #939

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 33 additions & 9 deletions src/frontend/src/utilities/CustomDrawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import SwipeableDrawer from '@mui/material/SwipeableDrawer';
import CoreModules from '../shared/CoreModules';
import AssetModules from '../shared/AssetModules';
import { NavLink } from 'react-router-dom';
import { createLoginWindow } from '../utilfunctions/login';
import { LoginActions } from '../store/slices/LoginSlice';
import { ProjectActions } from '../store/slices/ProjectSlice';

export default function CustomDrawer({ open, placement, size, type, onClose, onSignOut }) {
export default function CustomDrawer({ open, placement, size, type, onClose, onSignOut, setOpen }) {
const defaultTheme = CoreModules.useAppSelector((state) => state.theme.hotTheme);
const dispatch = CoreModules.useAppDispatch();

const onMouseEnter = (event) => {
const element = document.getElementById(`text${event.target.id}`);
Expand Down Expand Up @@ -81,6 +85,12 @@ export default function CustomDrawer({ open, placement, size, type, onClose, onS
},
];

const handleOnSignOut = () => {
setOpen(false);
dispatch(LoginActions.signOut(null));
dispatch(ProjectActions.clearProjects([]));
};

return (
<div>
<React.Fragment>
Expand Down Expand Up @@ -144,14 +154,11 @@ export default function CustomDrawer({ open, placement, size, type, onClose, onS
<NavLink
key={index}
to={menuDetails.ref}
style={{
textDecoration: 'inherit',
color: 'inherit',
fontFamily: 'inherit',
fontSize: '1.01587rem',
background: '#000000',
opacity: 0.8,
}}
className={`fmtm-no-underline fmtm-text-inherit fmtm-opacity-80 ${
menuDetails.name === 'Explore Projects' || menuDetails.name === 'Manage Organizations'
? 'lg:fmtm-hidden'
: ''
}`}
>
<CoreModules.ListItem
id={index.toString()}
Expand All @@ -164,6 +171,23 @@ export default function CustomDrawer({ open, placement, size, type, onClose, onS
</NavLink>
),
)}
<div className="fmtm-ml-4 fmtm-mt-2 lg:fmtm-hidden">
{token != null ? (
<div
className="fmtm-text-[#d73e3e] hover:fmtm-text-[#d73e3e] fmtm-cursor-pointer fmtm-opacity-80"
onClick={handleOnSignOut}
>
Sign Out
</div>
) : (
<div
className="fmtm-text-[#44546a] hover:fmtm-text-[#d73e3e] fmtm-cursor-pointer fmtm-opacity-80"
onClick={() => createLoginWindow('/')}
>
Sign In
</div>
)}
</div>
</CoreModules.List>
</CoreModules.Stack>
</SwipeableDrawer>
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/utilities/PrimaryAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default function PrimaryAppBar() {
size={windowSize}
type={type}
onSignOut={handleOnSignOut}
setOpen={setOpen}
/>
<CoreModules.AppBar
position="static"
Expand Down
Loading