-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathheaderUserLoggedInContent.tsx
More file actions
53 lines (51 loc) · 1.44 KB
/
headerUserLoggedInContent.tsx
File metadata and controls
53 lines (51 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { DropdownMenu, Divider, DropdownMenuItem, GenericLink } from 'ui';
import profileDefaultSvg from 'icons/profile-default.svg';
import Image from 'next/image';
import { AddNewTaskLink } from 'molecules/challengePage/addNewTaskLink/addNewTaskLink';
import { useRouter } from 'next/router';
type HeaderUserLoggedInItemProps = {
user: {
avatarSrc: string | null | undefined;
nickname: string | null | undefined;
};
};
export const HeaderUserLoggedInContent = ({
user,
}: HeaderUserLoggedInItemProps) => {
const router = useRouter();
const isOnChallengeNewPage = router.pathname.includes('/challenge/new');
return (
<div className="flex flex-col items-center lg:flex-row">
<div className="mr-2 h-10 w-10 ">
{user.avatarSrc ? (
<Image
className="rounded-full border"
src={user.avatarSrc}
alt="User Avatar"
width={100}
height={100}
/>
) : (
<Image
className="rounded-full border"
src={profileDefaultSvg}
alt="default user avatar"
height={100}
width={100}
/>
)}
</div>
<p className="m-0 p-0">Witaj, {user.nickname}!</p>
<DropdownMenu>
<GenericLink href="/profile">
<DropdownMenuItem>Profil</DropdownMenuItem>
</GenericLink>
<Divider />
<GenericLink href="/api/auth/logout">
<DropdownMenuItem>Wyloguj się</DropdownMenuItem>
</GenericLink>
</DropdownMenu>
{!isOnChallengeNewPage && <AddNewTaskLink />}
</div>
);
};