Disabled the navigation on the mobile menu

This commit is contained in:
Tiago Ribeiro
2024-02-09 16:48:25 +00:00
parent 03f78ceb46
commit 1895b9e183
2 changed files with 150 additions and 189 deletions

View File

@@ -13,9 +13,10 @@ interface Props {
onClose: () => void;
path: string;
user: User;
disableNavigation?: boolean;
}
export default function MobileMenu({ isOpen, onClose, path, user }: Props) {
export default function MobileMenu({isOpen, onClose, path, user, disableNavigation}: Props) {
const router = useRouter();
const logout = async () => {
@@ -34,8 +35,7 @@ export default function MobileMenu({ isOpen, onClose, path, user }: Props) {
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
leaveTo="opacity-0">
<div className="fixed inset-0 bg-black bg-opacity-25" />
</Transition.Child>
@@ -48,146 +48,105 @@ export default function MobileMenu({ isOpen, onClose, path, user }: Props) {
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
leaveTo="opacity-0 scale-95">
<Dialog.Panel className="flex h-screen w-full transform flex-col gap-8 overflow-hidden bg-white text-left align-middle text-black shadow-xl transition-all">
<Dialog.Title
as="header"
className="-md:flex w-full items-center justify-between px-8 py-2 shadow-sm md:hidden"
>
<Link href="/">
<Image
src="/logo_title.png"
alt="EnCoach logo"
width={69}
height={69}
/>
<Dialog.Title as="header" className="-md:flex w-full items-center justify-between px-8 py-2 shadow-sm md:hidden">
<Link href={disableNavigation ? "" : "/"}>
<Image src="/logo_title.png" alt="EnCoach logo" width={69} height={69} />
</Link>
<div
className="cursor-pointer"
onClick={onClose}
tabIndex={0}
>
<BsXLg
className="text-mti-purple-light text-2xl"
onClick={onClose}
/>
<div className="cursor-pointer" onClick={onClose} tabIndex={0}>
<BsXLg className="text-mti-purple-light text-2xl" onClick={onClose} />
</div>
</Dialog.Title>
<div className="flex h-full flex-col gap-6 px-8 text-lg">
<Link
href="/"
href={disableNavigation ? "" : "/"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
path === "/" && "text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}>
Dashboard
</Link>
{(user.type === "student" ||
user.type === "teacher" ||
user.type === "developer") && (
{(user.type === "student" || user.type === "teacher" || user.type === "developer") && (
<>
<Link
href="/exam"
href={disableNavigation ? "" : "/exam"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/exam" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
path === "/exam" && "text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}>
Exams
</Link>
<Link
href="/exercises"
href={disableNavigation ? "" : "/exercises"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/exercises" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
)}>
Exercises
</Link>
</>
)}
<Link
href="/stats"
href={disableNavigation ? "" : "/stats"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/stats" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
path === "/stats" && "text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}>
Stats
</Link>
<Link
href="/record"
href={disableNavigation ? "" : "/record"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/record" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
path === "/record" && "text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}>
Record
</Link>
{["admin", "developer", "agent", "corporate"].includes(
user.type,
) && (
{["admin", "developer", "agent", "corporate"].includes(user.type) && (
<Link
href="/payment-record"
href={disableNavigation ? "" : "/payment-record"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/payment-record" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
)}>
Payment Record
</Link>
)}
{["admin", "developer", "corporate", "teacher"].includes(
user.type,
) && (
{["admin", "developer", "corporate", "teacher"].includes(user.type) && (
<Link
href="/settings"
href={disableNavigation ? "" : "/settings"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/settings" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
path === "/settings" && "text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}>
Settings
</Link>
)}
{["admin", "developer", "agent"].includes(user.type) && (
<Link
href="/tickets"
href={disableNavigation ? "" : "/tickets"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/tickets" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
path === "/tickets" && "text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}>
Tickets
</Link>
)}
<Link
href="/profile"
href={disableNavigation ? "" : "/profile"}
className={clsx(
"w-fit transition duration-300 ease-in-out",
path === "/profile" &&
"text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}
>
path === "/profile" && "text-mti-purple-light border-b-mti-purple-light border-b-2 font-semibold ",
)}>
Profile
</Link>
<span
className={clsx(
"w-fit cursor-pointer justify-self-end transition duration-300 ease-in-out",
)}
onClick={logout}
>
className={clsx("w-fit cursor-pointer justify-self-end transition duration-300 ease-in-out")}
onClick={logout}>
Logout
</span>
</div>

View File

@@ -62,7 +62,9 @@ export default function Navbar({user, path, navDisabled = false, focusMode = fal
<TicketSubmission user={user} page={window.location.href} onClose={() => setIsTicketOpen(false)} />
</Modal>
{user && <MobileMenu path={path} isOpen={isMenuOpen} onClose={() => setIsMenuOpen(false)} user={user} />}
{user && (
<MobileMenu disableNavigation={disableNavigation} path={path} isOpen={isMenuOpen} onClose={() => setIsMenuOpen(false)} user={user} />
)}
<header className="-md:justify-between -md:px-4 relative flex w-full items-center bg-transparent py-2 md:gap-12 md:py-4">
<Link href={disableNavigation ? "" : "/"} className=" flex items-center gap-8 md:px-8">
<img src="/logo.png" alt="EnCoach's Logo" className="w-8 md:w-12" />