forked from joschan21/quill
-
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.
- Loading branch information
Showing
6 changed files
with
238 additions
and
23 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,101 @@ | ||
import { getUserSubscriptionPlan } from '@/lib/stripe' | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuSeparator, | ||
DropdownMenuTrigger, | ||
} from './ui/dropdown-menu' | ||
import { Button } from './ui/button' | ||
import { Avatar, AvatarFallback } from './ui/avatar' | ||
import Image from 'next/image' | ||
import { Icons } from './Icons' | ||
import Link from 'next/link' | ||
import { Gem } from 'lucide-react' | ||
import { LogoutLink } from '@kinde-oss/kinde-auth-nextjs/server' | ||
|
||
interface UserAccountNavProps { | ||
email: string | undefined | ||
name: string | ||
imageUrl: string | ||
} | ||
|
||
const UserAccountNav = async ({ | ||
email, | ||
imageUrl, | ||
name, | ||
}: UserAccountNavProps) => { | ||
const subscriptionPlan = await getUserSubscriptionPlan() | ||
|
||
return ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger | ||
asChild | ||
className='overflow-visible'> | ||
<Button className='rounded-full h-8 w-8 aspect-square bg-slate-400'> | ||
<Avatar className='relative w-8 h-8'> | ||
{imageUrl ? ( | ||
<div className='relative aspect-square h-full w-full'> | ||
<Image | ||
fill | ||
src={imageUrl} | ||
alt='profile picture' | ||
referrerPolicy='no-referrer' | ||
/> | ||
</div> | ||
) : ( | ||
<AvatarFallback> | ||
<span className='sr-only'>{name}</span> | ||
<Icons.user className='h-4 w-4 text-zinc-900' /> | ||
</AvatarFallback> | ||
)} | ||
</Avatar> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
|
||
<DropdownMenuContent className='bg-white' align='end'> | ||
<div className='flex items-center justify-start gap-2 p-2'> | ||
<div className='flex flex-col space-y-0.5 leading-none'> | ||
{name && ( | ||
<p className='font-medium text-sm text-black'> | ||
{name} | ||
</p> | ||
)} | ||
{email && ( | ||
<p className='w-[200px] truncate text-xs text-zinc-700'> | ||
{email} | ||
</p> | ||
)} | ||
</div> | ||
</div> | ||
|
||
<DropdownMenuSeparator /> | ||
|
||
<DropdownMenuItem asChild> | ||
<Link href='/dashboard'>Dashboard</Link> | ||
</DropdownMenuItem> | ||
|
||
<DropdownMenuItem asChild> | ||
{subscriptionPlan?.isSubscribed ? ( | ||
<Link href='/dashboard/billing'> | ||
Manage Subscription | ||
</Link> | ||
) : ( | ||
<Link href='/pricing'> | ||
Upgrade{' '} | ||
<Gem className='text-blue-600 h-4 w-4 ml-1.5' /> | ||
</Link> | ||
)} | ||
</DropdownMenuItem> | ||
|
||
<DropdownMenuSeparator /> | ||
|
||
<DropdownMenuItem className='cursor-pointer'> | ||
<LogoutLink>Log out</LogoutLink> | ||
</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
) | ||
} | ||
|
||
export default UserAccountNav |
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,50 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as AvatarPrimitive from "@radix-ui/react-avatar" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const Avatar = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
"relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
Avatar.displayName = AvatarPrimitive.Root.displayName | ||
|
||
const AvatarImage = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Image>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Image | ||
ref={ref} | ||
className={cn("aspect-square h-full w-full", className)} | ||
{...props} | ||
/> | ||
)) | ||
AvatarImage.displayName = AvatarPrimitive.Image.displayName | ||
|
||
const AvatarFallback = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Fallback>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Fallback | ||
ref={ref} | ||
className={cn( | ||
"flex h-full w-full items-center justify-center rounded-full bg-muted", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName | ||
|
||
export { Avatar, AvatarImage, AvatarFallback } |
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,7 @@ | ||
import { authMiddleware } from '@kinde-oss/kinde-auth-nextjs/server' | ||
|
||
export const config = { | ||
matcher: ['/dashboard/:path*', '/auth-callback'], | ||
} | ||
|
||
export default authMiddleware |