Fix logout state bug
Logging out didn't reset state, so the HeaderMenu still displayed the logged in menu
This commit is contained in:
parent
26fa33c4a7
commit
d656ba7eba
1 changed files with 8 additions and 3 deletions
|
|
@ -5,7 +5,7 @@ import clonedeep from 'lodash.clonedeep'
|
||||||
import { useSnapshot } from 'valtio'
|
import { useSnapshot } from 'valtio'
|
||||||
|
|
||||||
import api from '~utils/api'
|
import api from '~utils/api'
|
||||||
import { accountState } from '~utils/accountState'
|
import { accountState, initialAccountState } from '~utils/accountState'
|
||||||
import { appState, initialAppState } from '~utils/appState'
|
import { appState, initialAppState } from '~utils/appState'
|
||||||
|
|
||||||
import Header from '~components/Header'
|
import Header from '~components/Header'
|
||||||
|
|
@ -51,10 +51,15 @@ const TopHeader = () => {
|
||||||
function logout() {
|
function logout() {
|
||||||
removeCookie('user')
|
removeCookie('user')
|
||||||
|
|
||||||
accountState.authorized = false
|
// Clean state
|
||||||
|
const resetState = clonedeep(initialAccountState)
|
||||||
|
Object.keys(resetState).forEach((key) => {
|
||||||
|
if (key !== 'language')
|
||||||
|
accountState[key] = resetState[key]
|
||||||
|
})
|
||||||
|
|
||||||
appState.party.editable = false
|
appState.party.editable = false
|
||||||
|
|
||||||
// TODO: How can we log out without navigating to root
|
|
||||||
router.push('/')
|
router.push('/')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue