@@ -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' ;
1212import { getPrivilegeLevel } from '../../auth/ducks/selectors' ;
1313import { PRIMARY } from '../../utils/colors' ;
1414import { Routes } from '../../App' ;
15- import AuthClient from '../../auth/authClient' ;
1615import { asyncRequestIsComplete } from '../../utils/asyncRequest' ;
16+ import { logout } from '../../auth/ducks/thunks' ;
1717
1818const { Text } = Typography ;
1919
@@ -80,6 +80,7 @@ interface NavBarProps {
8080const 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