Skip to content

Commit

Permalink
Hide Panel on logout (#3774)
Browse files Browse the repository at this point in the history
* hide overlay

* hide panel on logout

* revert changes on Records

* dispatch toggle panel and public layer on logout

* change type to AppDispatch
  • Loading branch information
meghna0593 authored Jan 8, 2025
1 parent 9ed516f commit 1283b8e
Showing 1 changed file with 13 additions and 3 deletions.
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 { AppDispatch, 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: AppDispatch) => {
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

0 comments on commit 1283b8e

Please sign in to comment.