Skip to content

Commit 703b546

Browse files
committed
dispatched to our logout thunk
1 parent 7307389 commit 703b546

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/components/navbar/index.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import {
77
PrivilegeLevel,
88
UserAuthenticationReducerState,
99
} from '../../auth/ducks/types';
10-
import { C4CState, LOCALSTORAGE_STATE_KEY } from '../../store';
11-
import { connect } from 'react-redux';
10+
import { C4CState } from '../../store';
11+
import { connect, useDispatch } from 'react-redux';
1212
import { getPrivilegeLevel } from '../../auth/ducks/selectors';
1313
import { PRIMARY } from '../../utils/colors';
1414
import { Routes } from '../../App';
15-
import AuthClient from '../../auth/authClient';
1615
import { asyncRequestIsComplete } from '../../utils/asyncRequest';
16+
import { logout } from '../../auth/ducks/thunks';
1717

1818
const { Text } = Typography;
1919

@@ -80,6 +80,7 @@ interface NavBarProps {
8080
const NavBar: React.FC<NavBarProps> = ({ tokens }) => {
8181
const history = useHistory();
8282
const location = useLocation();
83+
const dispatch = useDispatch();
8384

8485
const privilegeLevel: PrivilegeLevel = getPrivilegeLevel(tokens);
8586
const links = {
@@ -99,9 +100,7 @@ const NavBar: React.FC<NavBarProps> = ({ tokens }) => {
99100
<Menu.Item
100101
onClick={() => {
101102
if (asyncRequestIsComplete(tokens)) {
102-
AuthClient.logout(tokens.result.refreshToken).then(() => {
103-
localStorage.removeItem(LOCALSTORAGE_STATE_KEY);
104-
});
103+
dispatch(logout());
105104
history.push(Routes.HOME);
106105
history.go(0); // force refresh if user is already on home page
107106
}

0 commit comments

Comments
 (0)