"use client"; import { useState } from "react"; import { ChevronsUpDown } from "lucide-react"; import { Avatar, AvatarFallback, AvatarImage, } from "@/app/_components/ui/avatar"; import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/app/_components/ui/dropdown-menu"; import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar, } from "@/app/_components/ui/sidebar"; import { IconLogout, IconSettings, IconSparkles } from "@tabler/icons-react"; import type { User } from "@/src/entities/models/users/users.model"; // import { signOut } from "@/app/(pages)/(auth)/action"; import { SettingsDialog } from "../settings/setting-dialog"; export function NavUser({ user }: { user: User | null }) { const { isMobile } = useSidebar(); const [isDialogOpen, setIsDialogOpen] = useState(false); // Use profile data with fallbacks const firstName = user?.profile?.first_name || ""; const lastName = user?.profile?.last_name || ""; const userEmail = user?.email || ""; const userAvatar = user?.profile?.avatar || ""; const getFullName = () => { return `${firstName} ${lastName}`.trim() || "User"; }; // Generate initials for avatar fallback const getInitials = () => { if (firstName && lastName) { return `${firstName[0]}${lastName[0]}`.toUpperCase(); } if (firstName) { return firstName[0].toUpperCase(); } if (userEmail) { return userEmail[0].toUpperCase(); } return "U"; }; // Handle dialog close after successful profile update const handleProfileUpdateSuccess = () => { setIsDialogOpen(false); // You might want to refresh the user data here }; return ( {getInitials()}
{getFullName()} {userEmail}
{getInitials()}
{getFullName()} {userEmail}
Upgrade to Pro { e.preventDefault(); }} > Settings } /> { }} className="space-x-2"> Log out
); }