-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: load user info on components after authenticate
- Loading branch information
Showing
12 changed files
with
101 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use client' | ||
|
||
import { signOut } from 'next-auth/react' | ||
import { HTMLAttributes } from 'react' | ||
import { twMerge } from 'tailwind-merge' | ||
|
||
type SignOutButtonProps = HTMLAttributes<HTMLButtonElement> | ||
|
||
export function SignOutButton(props: SignOutButtonProps) { | ||
function handleSignOut() { | ||
signOut({ callbackUrl: '/' }) | ||
} | ||
|
||
return ( | ||
<button | ||
onClick={handleSignOut} | ||
className={twMerge( | ||
'flex w-full items-center justify-between', | ||
props.className, | ||
)} | ||
{...props} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use client' | ||
|
||
import { useSession } from 'next-auth/react' | ||
import { Avatar, AvatarImage } from './ui/avatar' | ||
|
||
export function UserAvatar() { | ||
const { data } = useSession() | ||
|
||
const user = data?.user | ||
|
||
return ( | ||
<Avatar className="h-8 w-8"> | ||
{user?.avatarUrl && <AvatarImage src={user.avatarUrl} alt="" />} | ||
</Avatar> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use client' | ||
|
||
import { useSession } from 'next-auth/react' | ||
|
||
export function UserInfoLabel() { | ||
const { data } = useSession() | ||
|
||
const user = data?.user | ||
|
||
return ( | ||
<div className="flex flex-col space-y-2"> | ||
<p className="text-sm font-medium leading-none">{user?.name}</p> | ||
<p className="text-xs leading-none text-muted-foreground"> | ||
{user?.email} | ||
</p> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters