Skip to content

Commit b878aea

Browse files
committed
Enhance Header component by adding AvatarFallback for user initials when profile picture is unavailable. Update Avatar component to ensure proper export of AvatarFallback. Clean up code formatting for consistency.
1 parent bf6c6ff commit b878aea

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

frontend/public/img/icon_logo.png

3.04 KB
Loading

frontend/src/components/Header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Button } from "@/components/ui/button";
33
import { Link } from "react-router-dom";
44
import { LogOut } from "lucide-react";
55
import { useAuth } from "../contexts/AuthContext";
6-
import { Avatar, AvatarImage } from "./ui/avatar";
6+
import { Avatar, AvatarFallback, AvatarImage } from "./ui/avatar";
77
// No props needed as we'll use the auth context
88
const Header: React.FC = () => {
99
const { login, logout, user, isAuthenticated } = useAuth();
@@ -44,6 +44,7 @@ const Header: React.FC = () => {
4444
>
4545
<Avatar title={user?.name}>
4646
<AvatarImage src={user?.picture} />
47+
<AvatarFallback>{user?.name?.charAt(0)}</AvatarFallback>
4748
</Avatar>
4849
<span>{user?.name ?? "Profile"}</span>
4950
</div>

frontend/src/components/ui/avatar.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import * as React from "react"
2-
import * as AvatarPrimitive from "@radix-ui/react-avatar"
1+
import * as React from "react";
2+
import * as AvatarPrimitive from "@radix-ui/react-avatar";
33

4-
import { cn } from "@/lib/utils"
4+
import { cn } from "@/lib/utils";
55

66
function Avatar({
77
className,
@@ -16,7 +16,7 @@ function Avatar({
1616
)}
1717
{...props}
1818
/>
19-
)
19+
);
2020
}
2121

2222
function AvatarImage({
@@ -29,7 +29,7 @@ function AvatarImage({
2929
className={cn("aspect-square size-full", className)}
3030
{...props}
3131
/>
32-
)
32+
);
3333
}
3434

3535
function AvatarFallback({
@@ -45,7 +45,7 @@ function AvatarFallback({
4545
)}
4646
{...props}
4747
/>
48-
)
48+
);
4949
}
5050

51-
export { Avatar, AvatarImage, AvatarFallback }
51+
export { Avatar, AvatarImage, AvatarFallback };

0 commit comments

Comments
 (0)