-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwrapper.tsx
More file actions
157 lines (152 loc) · 6.32 KB
/
wrapper.tsx
File metadata and controls
157 lines (152 loc) · 6.32 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
'use client';
import Image from 'next/image';
import { IoClose as Close } from 'react-icons/io5';
import Link from 'next/link';
import { HEADER_MENU } from '@frontend/utils/constants';
import { HiOutlineMenu as Menu } from 'react-icons/hi';
import React, { ReactNode } from 'react';
import { usePathname } from 'next/navigation';
import { Footer } from '@frontend/sections';
import { useSession, signOut } from 'next-auth/react';
import { Toaster } from 'react-hot-toast';
import dynamic from 'next/dynamic';
import { NotificationBell } from '../notification/novu';
import clsx from 'clsx';
const ShowEvent = dynamic(() => import('@frontend/utils/show.event'), {
ssr: false,
});
export const Wrapper = ({ children }: { children: ReactNode }) => {
const pathName = usePathname();
const session = useSession();
const toggleMenu = (force = false) => {
const navLinks = document.getElementById('navLinks');
navLinks?.classList.toggle('opacity-0', force);
navLinks?.classList.toggle('pointer-events-none', force);
document.documentElement.style.overflow = force ? 'auto' : 'hidden';
// navLinks?.classList.toggle('hidden', force);
};
React.useEffect(() => {
toggleMenu(true);
}, [pathName]);
return (
<>
<Toaster />
<ShowEvent />
{session.status === 'authenticated' && (
<Link
href="/dashboard/bonuses"
className="cursor-pointer text-black text-[20px] bg-gradient-to-b from-[#FBFF14] to-[#DBB800] group-hover:from-[#FCFF63] group-hover:to-[#FFDD29] text-center p-[3px]"
>
Check out the latest bonuses 🚀
</Link>
)}
<div />
<nav
className={clsx(
session.status === 'authenticated' && 'top-[23px]',
'absolute z-50 flex items-center justify-between px-5 py-[18px] md:py-0 max-w-[1400px] w-full left-[50%] -translate-x-[50%]'
)}
>
<div className="mr-[20px]">
<Link href="/">
<Image src="/svgs/Logo.svg" alt="" width={40} height={48} />
</Link>
</div>
<div className="flex items-start md:w-full">
<div
id="navLinks"
className="pointer-events-none fixed top-0 left-0 z-[99] list-none items-center bg-black opacity-0 transition-opacity duration-200 md:pointer-events-auto md:relative md:flex md:bg-transparent md:opacity-100 min-h-screen h-fit md:min-h-fit w-full"
>
<div className="mx-[20px] my-[25px] flex items-center justify-end md:hidden">
<div className="flex h-6 w-6 items-center justify-center">
<Close size={30} onClick={() => toggleMenu(true)} />
</div>
</div>
<ul className="mx-[20px] mt-[3px] flex flex-col items-center justify-start md:mx-[0px] md:mt-[0px] md:flex-row md:items-center gap-[25px] md:gap-[40px] md:w-full">
<Link
href="/"
className="md:hidden mb-[25px]"
onClick={() => toggleMenu(true)}
>
<Image src="/svgs/Logo.svg" alt="" width={40} height={48} />
</Link>
{HEADER_MENU.map((item, index) => (
<Link
href={
item?.name === 'Ticket'
? session?.status === 'authenticated'
? // @ts-ignore
`/dashboard/ticket`
: item?.path
: item?.path
}
key={index}
onClick={() => toggleMenu(true)}
>
<li
className={`cursor-pointer border-b-[${
index < HEADER_MENU.length - 1 ? 1 : 0
}px] border-[#FFFFFF33] text-[24px] text-white transition duration-300 ease-in active:text-[#FBFF14] hover:text-[#A489FF] md:border-none md:py-[30px] uppercase font-bebas`}
>
{item?.name}
</li>
</Link>
))}
{session.status == 'authenticated' && (
<Link
className="flex-1"
href="/dashboard"
onClick={() => toggleMenu(true)}
>
<li
className={`cursor-pointer border-[#FFFFFF33] text-[24px] text-white transition duration-300 ease-in active:text-[#FBFF14] hover:text-[#A489FF] md:border-none md:py-[30px] uppercase font-bebas`}
>
Your Team
</li>
</Link>
)}
{session.status == 'authenticated' &&
// @ts-ignore
session?.data?.user?.isMod && (
<Link
href="/dashboard/manage"
onClick={() => toggleMenu(true)}
>
<li
className={`cursor-pointer border-[#FFFFFF33] text-[24px] text-white transition duration-300 ease-in active:text-[#FBFF14] hover:text-[#A489FF] md:border-none md:py-[30px] uppercase font-bebas`}
>
Manage Repositories
</li>
</Link>
)}
{session.status == 'authenticated' && (
<li
className={`cursor-pointer transition duration-300 ease-in active:text-[#FBFF14] hover:text-[#A489FF] hidden md:block md:border-none md:py-[30px]`}
>
<NotificationBell
userId={session?.data?.user?.id as string}
/>
</li>
)}
{session.status == 'authenticated' && (
<li
onClick={() => signOut()}
className={`cursor-pointer border-[#FFFFFF33] text-[24px] text-white transition duration-300 ease-in active:text-[#FBFF14] hover:text-[#A489FF] md:border-none md:py-[30px] uppercase font-bebas`}
>
Logout
</li>
)}
</ul>
</div>
<button className="md:hidden" onClick={() => toggleMenu()}>
<Menu size={30} />
</button>
</div>
</nav>
<div className="mt-[100px] clear-both w-full max-w-[1400px] mx-auto px-5 min-h-[500px]">
{children}
</div>
<Footer />
</>
);
};