- Rename directory keep-notes -> memento-note with all code references - Prisma: SQLite -> PostgreSQL (both app and MCP server schemas) - Sync MCP schema with main app (add missing fields, relations, indexes) - Delete 17 SQLite migrations (clean slate for PostgreSQL) - Remove SQLite dependencies (@libsql/client, better-sqlite3, etc.) - Fix MCP server: hardcoded Windows DB paths -> DATABASE_URL env var - Fix MCP server: .dockerignore excluded index-sse.js (SSE mode broken) - MCP Dockerfile: node:20 -> node:22 - Docker Compose: add postgres service, remove SQLite volume - Generate favicon.ico, icon-192.png, icon-512.png, apple-icon.png - Update layout.tsx icons and manifest.json for PNG icons - Update all .env files for PostgreSQL - Rewrite README.md with updated sections - Remove mcp-server/node_modules and prisma/client-generated from git tracking Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
'use client'
|
|
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuGroup,
|
|
DropdownMenuItem,
|
|
DropdownMenuLabel,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from '@/components/ui/dropdown-menu'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'
|
|
import { useSession, signOut } from 'next-auth/react'
|
|
import { useRouter } from 'next/navigation'
|
|
import { LogOut, Settings, User, Shield } from 'lucide-react'
|
|
import { useLanguage } from '@/lib/i18n'
|
|
|
|
export function UserNav({ user }: { user?: any }) {
|
|
const { data: session } = useSession()
|
|
const router = useRouter()
|
|
const { t } = useLanguage()
|
|
|
|
const currentUser = user || session?.user
|
|
|
|
if (!currentUser) return null
|
|
|
|
const userRole = (currentUser as any).role || currentUser.role
|
|
const userInitials = currentUser.name
|
|
? currentUser.name.split(' ').map((n: string) => n[0]).join('').toUpperCase().substring(0, 2)
|
|
: 'U'
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
|
|
<Avatar className="h-8 w-8">
|
|
<AvatarImage src={currentUser.image || ''} alt={currentUser.name || ''} />
|
|
<AvatarFallback>{userInitials}</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">{currentUser.name}</p>
|
|
<p className="text-xs leading-none text-muted-foreground">
|
|
{currentUser.email}
|
|
</p>
|
|
</div>
|
|
</DropdownMenuLabel>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuGroup>
|
|
<DropdownMenuItem onClick={() => router.push('/settings/profile')}>
|
|
<User className="mr-2 h-4 w-4" />
|
|
<span>{t('nav.profile')}</span>
|
|
</DropdownMenuItem>
|
|
{userRole === 'ADMIN' && (
|
|
<DropdownMenuItem onClick={() => router.push('/admin')}>
|
|
<Shield className="mr-2 h-4 w-4" />
|
|
<span>{t('nav.adminDashboard')}</span>
|
|
</DropdownMenuItem>
|
|
)}
|
|
<DropdownMenuItem onClick={() => router.push('/settings')}>
|
|
<Settings className="mr-2 h-4 w-4" />
|
|
<span>{t('nav.diagnostics')}</span>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuGroup>
|
|
<DropdownMenuSeparator />
|
|
<DropdownMenuItem onClick={() => signOut({ callbackUrl: '/login' })}>
|
|
<LogOut className="mr-2 h-4 w-4" />
|
|
<span>{t('nav.logout')}</span>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|