Skip to content

Commit

Permalink
useAuth directly in userdetails component
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikmonsen committed Nov 13, 2024
1 parent a0863fa commit 89bc0cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/components/ui/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ThemeToggleButton} from '@/components/ui/ThemeToggleButton';


export default function Header() {
const { authenticated , user } = useAuth();
const { authenticated } = useAuth();
const router = useRouter();

return (
Expand All @@ -30,7 +30,7 @@ export default function Header() {
<ThemeToggleButton />
{ authenticated ? (
<>
<UserDetails name={user?.name ?? ''}/>
<UserDetails />
<LogoutButton className="pl-2.5"/>
</>
) : <></>}
Expand Down
11 changes: 6 additions & 5 deletions src/components/ui/UserDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import {User} from '@nextui-org/user';
import {FC} from 'react';
import {Avatar} from '@nextui-org/avatar';
import {useAuth} from '@/providers/AuthProvider';

interface UserDetailsProps {
name: string;
className?: string;
}

export const UserDetails: FC<UserDetailsProps> = ({ name, className }) => {
const initials = name.split(' ').map(n => n[0]?.toUpperCase()).join('');
export const UserDetails: FC<UserDetailsProps> = ({ className }) => {
const { user } = useAuth();
const initials = user?.name.split(' ').map(n => n[0]?.toUpperCase()).join('');

return (
<div className={`${className}`}>
Expand All @@ -22,10 +23,10 @@ export const UserDetails: FC<UserDetailsProps> = ({ name, className }) => {
</div>
<div className="hidden lg:flex items-center ">
<User
name={name}
name={user?.name}
avatarProps={{
name: initials,
isBordered: false,
isBordered: false
}}
/>
</div>
Expand Down

0 comments on commit 89bc0cc

Please sign in to comment.