Sootzani/components/NavbarPanel.tsx

77 lines
2.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"use client";
import React, { useEffect, useState } from "react";
import Link from "next/link";
import { AdminMenuItems, ControllerMenuItems } from "@/constants";
import { usePathname } from "next/navigation";
export default function NavbarPanel() {
const pathname = usePathname();
const [role, setRole] = useState<string | null>("");
useEffect(() => {
const userRole = localStorage.getItem("Sootzani_Role");
setRole(userRole);
}, []);
const menus = {
Admin: AdminMenuItems,
Inspector: ControllerMenuItems,
};
const selectedMenu = menus[role as keyof typeof menus];
return (
<div
className="fixed flex flex-col-reverse justify-between items-start gap-3
sm:flex-row sm:items-center sm:gap-0
w-full px-8 py-1 z-10 bg-blue max-md:px-4
"
>
<div className=" flex items-center gap-8 max-md:gap-4">
<p className="text-white inline-block bg-clip-text text-sm font-bold max-md:text-xs max-md:font-medium">
پنل کاربری |
</p>
<div className="flex flex-row gap-7 max-md:gap-3">
{role && (
<>
{selectedMenu.map(
(item: { id: number; name: string; href: string }) => {
return (
<Link key={item.id} href={item.href}>
<p
className="text-white font-normal text-sm max-md:text-xs
hover:bg-white/50 rounded-sm p-1
animate-out duration-300 "
>
{item.name}
</p>
</Link>
);
}
)}
</>
)}
{/* {AdminMenuItems.map((item) => {
return (
<Link key={item.id} href={item.href}>
<p
className="text-white font-normal text-sm max-md:text-xs
hover:bg-white/50 rounded-sm p-1
animate-out duration-300 "
>
{item.name}
</p>
</Link>
);
})} */}
</div>
</div>
<h1 className="text-white inline-block bg-clip-text before:max-md:hidden text-sm font-bold max-md:text-xs max-md:font-medium">
{role === 'Admin' ? 'نام و نام خانوادگی (ادمین)' : 'نام و نام خانوادگی (بازرس)'}
</h1>
</div>
);
}