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

Hide Panel on logout #3774

Merged
merged 5 commits into from
Jan 8, 2025
Merged
Changes from 4 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
16 changes: 13 additions & 3 deletions app/src/UI/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
MenuItem,
Switch
} from '@mui/material';
import { useDispatch } from 'react-redux';
import {
AUTH_OPEN_OFFLINE_USER_SELECTION_DIALOG,
AUTH_SIGNIN_REQUEST,
Expand All @@ -39,12 +38,13 @@ import invbclogo from '/assets/InvasivesBC_Icon.svg';
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
import ArrowLeftIcon from '@mui/icons-material/ArrowLeft';
import { RENDER_DEBUG } from 'UI/App';
import { useSelector } from 'utils/use_selector';
import { useDispatch, useSelector } from 'utils/use_selector';
import { selectAuth } from 'state/reducers/auth';
import { OfflineSyncHeaderButton } from 'UI/Header/OfflineSyncHeaderButton';
import RefreshButton from './RefreshButton';
import { MOBILE } from 'state/build-time-config';
import NetworkActions from 'state/actions/network/NetworkActions';
import MapActions from 'state/actions/map';

type TabPredicate =
| 'authenticated_any'
Expand Down Expand Up @@ -185,10 +185,20 @@ const LoginButton = ({ labelText = 'Login' }) => {

const LogoutButton = () => {
const dispatch = useDispatch();
const signOutAndTogglePanel = () => {
return (dispatch: any) => {
dispatch({
type: TOGGLE_PANEL,
payload: { panelOpen: false }
});
dispatch({ type: AUTH_SIGNOUT_REQUEST });
dispatch(MapActions.toggleOverlay('public_layer'));
};
};
return (
<MenuItem
onClick={() => {
dispatch({ type: AUTH_SIGNOUT_REQUEST });
dispatch(signOutAndTogglePanel());
}}
>
<ListItemIcon>
Expand Down
Loading