summaryrefslogtreecommitdiff
path: root/src/modules/profile-card/components/Dropdown.tsx
blob: f6f58c98261200dfec0e9e748b96c668778d32d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
"use client";
import { DropdownItem, DropdownMenu, DropdownTrigger, Dropdown as UIDropdown } from "@nextui-org/react"
import { MoreVerticalIcon } from "lucide-react"
import { deleteCookie } from "cookies-next"
import { useRouter } from "next/navigation";

const Dropdown = () => {
  const router = useRouter()

  const logout = () => {
    deleteCookie('credential')
    router.push('/login')
  }

  return (
    <UIDropdown>
      <DropdownTrigger>
        <button type="button" className="p-1">
          <MoreVerticalIcon size={20} />
        </button>
      </DropdownTrigger>
      <DropdownMenu>
        <DropdownItem
          key="logout"
          className="text-danger-600"
          color="danger"
          onPress={logout}
        >
          Logout
        </DropdownItem>
      </DropdownMenu>
    </UIDropdown>
  )
}

export default Dropdown