Skip to content

Commit

Permalink
bugfix: signout issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Nov 20, 2024
1 parent 575aeb2 commit 1866c18
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions ui2/src/components/Header/UserMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import {useSelector} from "react-redux"
import type {User} from "@/types.ts"
import {Group, Menu, UnstyledButton} from "@mantine/core"
import {
IconChevronRight,
IconUser,
IconApi,
IconInfoSquareRounded,
IconLogout
IconChevronRight,
IconLogout,
IconUser
} from "@tabler/icons-react"
import type {User} from "@/types.ts"
import Cookies from "js-cookie"
import {useSelector} from "react-redux"

import {
selectCurrentUser,
selectCurrentUserStatus,
selectCurrentUserError
selectCurrentUserError,
selectCurrentUserStatus
} from "@/slices/currentUser.ts"

export default function UserMenu() {
const status = useSelector(selectCurrentUserStatus)
const error = useSelector(selectCurrentUserError)
const user = useSelector(selectCurrentUser) as User

const onSignOutClicked = () => {
Cookies.remove("access_token")
let a = document.createElement("a")
a.href = "/login"
a.click()
}

if (status == "loading") {
return <>Loading...</>
}
Expand All @@ -43,20 +50,14 @@ export default function UserMenu() {
<Menu.Item>
<Group>
<IconApi />
REST API
</Group>
</Menu.Item>
<Menu.Item>
<Group>
<IconInfoSquareRounded />
About
<a href="/docs">REST API</a>
</Group>
</Menu.Item>
<Menu.Divider />
<Menu.Item>
<Group>
<IconLogout />
Sign Out
<a onClick={onSignOutClicked}>Sign Out</a>
</Group>
</Menu.Item>
</Menu.Dropdown>
Expand Down

0 comments on commit 1866c18

Please sign in to comment.