profi sayfası
This commit is contained in:
@@ -14,13 +14,30 @@ import {
|
||||
DropdownMenuItem,
|
||||
DropdownMenuLabel,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuShortcut,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu"
|
||||
import { supabase } from "@/lib/supabase"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { useEffect, useState } from "react"
|
||||
import { User } from "@supabase/supabase-js"
|
||||
|
||||
export function UserNav() {
|
||||
interface UserProfile {
|
||||
full_name: string | null
|
||||
email: string | null
|
||||
role: string | null
|
||||
}
|
||||
|
||||
interface UserNavProps {
|
||||
user: {
|
||||
email?: string | null
|
||||
} | null
|
||||
profile: {
|
||||
full_name?: string | null
|
||||
role?: string | null
|
||||
} | null
|
||||
}
|
||||
|
||||
export function UserNav({ user, profile }: UserNavProps) {
|
||||
const router = useRouter()
|
||||
|
||||
const handleSignOut = async () => {
|
||||
@@ -29,22 +46,31 @@ export function UserNav() {
|
||||
router.refresh()
|
||||
}
|
||||
|
||||
const getInitials = (name: string) => {
|
||||
return name
|
||||
.split(' ')
|
||||
.map((n) => n[0])
|
||||
.join('')
|
||||
.toUpperCase()
|
||||
.substring(0, 2)
|
||||
}
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
|
||||
<Avatar className="h-8 w-8">
|
||||
<AvatarImage src="/avatars/01.png" alt="@parakasa" />
|
||||
<AvatarFallback>PK</AvatarFallback>
|
||||
<AvatarImage src="/avatars/01.png" alt={profile?.full_name || "@parakasa"} />
|
||||
<AvatarFallback>{profile?.full_name ? getInitials(profile.full_name) : 'PK'}</AvatarFallback>
|
||||
</Avatar>
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="w-56" align="end" forceMount>
|
||||
<DropdownMenuLabel className="font-normal">
|
||||
<div className="flex flex-col space-y-1">
|
||||
<p className="text-sm font-medium leading-none">Admin</p>
|
||||
<p className="text-sm font-medium leading-none">{profile?.full_name || 'Kullanıcı'}</p>
|
||||
<p className="text-xs leading-none text-muted-foreground">
|
||||
admin@parakasa.com
|
||||
{user?.email}
|
||||
</p>
|
||||
</div>
|
||||
</DropdownMenuLabel>
|
||||
@@ -52,23 +78,18 @@ export function UserNav() {
|
||||
<DropdownMenuGroup>
|
||||
<Link href="/dashboard/profile">
|
||||
<DropdownMenuItem className="cursor-pointer">
|
||||
Profil
|
||||
Profil Bilgileri
|
||||
</DropdownMenuItem>
|
||||
</Link>
|
||||
<Link href="/dashboard/users">
|
||||
<Link href="/dashboard/profile/password">
|
||||
<DropdownMenuItem className="cursor-pointer">
|
||||
Kullanıcılar
|
||||
</DropdownMenuItem>
|
||||
</Link>
|
||||
<Link href="/dashboard/settings">
|
||||
<DropdownMenuItem className="cursor-pointer">
|
||||
Ayarlar
|
||||
Şifre Değiştir
|
||||
</DropdownMenuItem>
|
||||
</Link>
|
||||
</DropdownMenuGroup>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem onClick={handleSignOut}>
|
||||
Çıkış Yap
|
||||
<DropdownMenuItem onClick={handleSignOut} className="cursor-pointer text-red-600 focus:text-red-600">
|
||||
Çıkış
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
|
||||
Reference in New Issue
Block a user