Files
vito/resources/js/components/user-info.tsx
2025-05-21 17:21:10 +02:00

21 lines
845 B
TypeScript

import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
import { useInitials } from '@/hooks/use-initials';
import { type User } from '@/types/user';
export function UserInfo({ user, showEmail = false }: { user: User; showEmail?: boolean }) {
const getInitials = useInitials();
return (
<>
<Avatar className="h-8 w-8 rounded-md">
<AvatarImage src={user.avatar} alt={user.name} />
<AvatarFallback className="bg-accent text-accent-foreground border-ring rounded-md border">{getInitials(user.name)}</AvatarFallback>
</Avatar>
<div className="grid flex-1 text-left text-sm leading-tight">
<span className="truncate font-medium">{user.name}</span>
{showEmail && <span className="text-muted-foreground truncate text-xs">{user.email}</span>}
</div>
</>
);
}