forked from RiseUP/riseup-squad20
feat(header): mostrar foto do usuário no avatar do topo
Usa profile.foto_url|fotoUrl|avatar_url como src e fallback com iniciais geradas a partir do nome/e-mail.
This commit is contained in:
parent
4e0c246e05
commit
68c38dba88
@ -296,7 +296,7 @@ export default function PerfilPage() {
|
|||||||
className="bg-blue-600 hover:bg-blue-700"
|
className="bg-blue-600 hover:bg-blue-700"
|
||||||
onClick={handleEditClick}
|
onClick={handleEditClick}
|
||||||
>
|
>
|
||||||
✏️ Editar Perfil
|
Editar Perfil
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
|
|||||||
@ -1562,7 +1562,7 @@ export default function PacientePage() {
|
|||||||
className="bg-blue-600 hover:bg-blue-700 w-full sm:w-auto whitespace-nowrap text-xs sm:text-sm"
|
className="bg-blue-600 hover:bg-blue-700 w-full sm:w-auto whitespace-nowrap text-xs sm:text-sm"
|
||||||
onClick={() => setIsEditingProfile(true)}
|
onClick={() => setIsEditingProfile(true)}
|
||||||
>
|
>
|
||||||
✏️ Editar Perfil
|
Editar Perfil
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col sm:flex-row gap-2 w-full sm:w-auto">
|
<div className="flex flex-col sm:flex-row gap-2 w-full sm:w-auto">
|
||||||
|
|||||||
@ -2780,7 +2780,7 @@ const ProfissionalPage = () => {
|
|||||||
className="bg-blue-600 hover:bg-blue-700 text-xs sm:text-sm w-full sm:w-auto"
|
className="bg-blue-600 hover:bg-blue-700 text-xs sm:text-sm w-full sm:w-auto"
|
||||||
onClick={() => setIsEditingProfile(true)}
|
onClick={() => setIsEditingProfile(true)}
|
||||||
>
|
>
|
||||||
✏️ Editar Perfil
|
Editar Perfil
|
||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex gap-2 w-full sm:w-auto">
|
<div className="flex gap-2 w-full sm:w-auto">
|
||||||
|
|||||||
@ -60,9 +60,32 @@ export function PagesHeader({ title = "", subtitle = "" }: { title?: string, sub
|
|||||||
className="relative h-8 w-8 rounded-full border-2 border-border hover:border-primary"
|
className="relative h-8 w-8 rounded-full border-2 border-border hover:border-primary"
|
||||||
onClick={() => setDropdownOpen(!dropdownOpen)}
|
onClick={() => setDropdownOpen(!dropdownOpen)}
|
||||||
>
|
>
|
||||||
|
{/* Mostrar foto do usuário quando disponível; senão, mostrar fallback com iniciais */}
|
||||||
<Avatar className="h-8 w-8">
|
<Avatar className="h-8 w-8">
|
||||||
<AvatarImage src="/avatars/01.png" alt="@usuario" />
|
{
|
||||||
<AvatarFallback className="bg-primary text-primary-foreground font-semibold">RA</AvatarFallback>
|
(() => {
|
||||||
|
const userPhoto = (user as any)?.profile?.foto_url || (user as any)?.profile?.fotoUrl || (user as any)?.profile?.avatar_url
|
||||||
|
const alt = user?.name || user?.email || 'Usuário'
|
||||||
|
|
||||||
|
const getInitials = (name?: string, email?: string) => {
|
||||||
|
if (name) {
|
||||||
|
const parts = name.trim().split(/\s+/)
|
||||||
|
const first = parts[0]?.charAt(0) ?? ''
|
||||||
|
const second = parts[1]?.charAt(0) ?? ''
|
||||||
|
return (first + second).toUpperCase() || (email?.charAt(0) ?? 'U').toUpperCase()
|
||||||
|
}
|
||||||
|
if (email) return email.charAt(0).toUpperCase()
|
||||||
|
return 'U'
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<AvatarImage src={userPhoto || undefined} alt={alt} />
|
||||||
|
<AvatarFallback className="bg-primary text-primary-foreground font-semibold">{getInitials(user?.name, user?.email)}</AvatarFallback>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
})()
|
||||||
|
}
|
||||||
</Avatar>
|
</Avatar>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user