Skip to content

Commit

Permalink
revert(dashboard): logout button show up (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
hazimoarafa authored Jun 6, 2024
1 parent ae7dc58 commit 13eba01
Showing 1 changed file with 38 additions and 41 deletions.
79 changes: 38 additions & 41 deletions dashboard/src/app/(authenticated)/components/Principal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { authOptions } from '@/app/api/auth/[...nextauth]/authOptions'
import { useWhoAmI } from '@/contexts/WhoAmIContext'
import { Menu, Transition } from '@headlessui/react'
import { signOut } from 'next-auth/react'
Expand All @@ -10,46 +9,44 @@ function classNames(...classes: Array<string | boolean>) {
export const Principal: FC = () => {
const { user } = useWhoAmI()
return (
authOptions.providers.length > 0 && (
<Menu as="div" className="relative inline-block text-left">
<div>
<Menu.Button className="inline-flex w-full justify-center gap-x-1.5 px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm">
<div className="relative inline-flex h-8 w-8 items-center justify-center overflow-hidden rounded-full bg-gray-100 dark:bg-gray-600">
<span className="font-medium text-gray-600 dark:text-gray-300">{user?.name?.at(0)}</span>
</div>
</Menu.Button>
</div>
<Menu as="div" className="relative inline-block text-left">
<div>
<Menu.Button className="inline-flex w-full justify-center gap-x-1.5 px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm">
<div className="relative inline-flex h-8 w-8 items-center justify-center overflow-hidden rounded-full bg-gray-100 dark:bg-gray-600">
<span className="font-medium text-gray-600 dark:text-gray-300">{user?.name?.at(0)}</span>
</div>
</Menu.Button>
</div>

<Transition
as={Fragment}
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Menu.Items className="absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
<div className="py-1">
<Menu.Item>
{({ active }) => (
<button
onClick={() => {
signOut()
}}
className={classNames(
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700',
'block w-full px-4 py-2 text-left text-sm'
)}
>
Sign out
</button>
)}
</Menu.Item>
</div>
</Menu.Items>
</Transition>
</Menu>
)
<Transition
as={Fragment}
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<Menu.Items className="absolute right-0 z-10 mt-2 w-56 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none">
<div className="py-1">
<Menu.Item>
{({ active }) => (
<button
onClick={() => {
signOut()
}}
className={classNames(
active ? 'bg-gray-100 text-gray-900' : 'text-gray-700',
'block w-full px-4 py-2 text-left text-sm'
)}
>
Sign out
</button>
)}
</Menu.Item>
</div>
</Menu.Items>
</Transition>
</Menu>
)
}

0 comments on commit 13eba01

Please sign in to comment.