diff --git a/src/app/components/Header/index.tsx b/src/app/components/Header/index.tsx index 4891d0d..ae5b35d 100644 --- a/src/app/components/Header/index.tsx +++ b/src/app/components/Header/index.tsx @@ -12,9 +12,25 @@ import { import { useSession } from "next-auth/react"; import { ThemeSwitcher } from "../ThemeSwitcher/ThemeSwitcher"; +const getInitials = (name: string) => { + if (!name) return ""; + + const nameParts = name.split(" "); + if (nameParts.length === 1) { + return name; + } + + const firstInitial = nameParts[0]?.[0] || ""; + const secondInitial = nameParts[1]?.[0] || nameParts[0]?.[1] || ""; + + return firstInitial + secondInitial; +}; + export const Header = () => { const { data: session } = useSession(); + const initials = session?.user?.name ? getInitials(session.user.name) : ""; + return ( @@ -29,7 +45,7 @@ export const Header = () => { as="button" className="transition-transform" color="secondary" - name={session?.user?.name} + name={initials} size="sm" /> diff --git a/src/app/components/ThemeSwitcher/ThemeSwitcher.tsx b/src/app/components/ThemeSwitcher/ThemeSwitcher.tsx index 21ea773..64bf4b8 100644 --- a/src/app/components/ThemeSwitcher/ThemeSwitcher.tsx +++ b/src/app/components/ThemeSwitcher/ThemeSwitcher.tsx @@ -13,11 +13,12 @@ export const ThemeSwitcher = () => { if (!mounted) return null; return ( -
- {theme === "light" ? ( - ) : ( - - )} -
+ ); };