79 lines
2.5 KiB
TypeScript
79 lines
2.5 KiB
TypeScript
"use client";
|
||
|
||
import React, { useEffect, useState } from "react";
|
||
import { Input } from "./ui/input";
|
||
import Image from "next/image";
|
||
import { menuItems } from "@/constants";
|
||
import Link from "next/link";
|
||
import Login from "./Login";
|
||
import { Button } from "./ui/button";
|
||
import { usePathname } from "next/navigation";
|
||
import TopNav from "./TopNav";
|
||
import { isAuthorized } from "@/lib/utils";
|
||
import useToken from "@/store/useToken";
|
||
import { DropdownMenu } from "@radix-ui/react-dropdown-menu";
|
||
import ProfileDropDown from "./ProfileDropDown";
|
||
|
||
export default function Navbar() {
|
||
const pathname = usePathname();
|
||
const isAuth = useToken((state) => state.token);
|
||
const [auth, setAuth] = useState<boolean>(isAuth);
|
||
useToken.persist.rehydrate();
|
||
useEffect(() => {
|
||
setAuth(isAuth);
|
||
}, [isAuth]);
|
||
return (
|
||
<div
|
||
className={`max-md:hidden left-0 right-0 top-0 z-10 ${
|
||
pathname === "/" ? "absolute" : "sticky"
|
||
}`}
|
||
>
|
||
<TopNav />
|
||
<div className=" bg-white h-16 shadow-md flex items-center justify-between py-2 px-8">
|
||
<div className=" flex ">
|
||
<div className=" flex items-center ">
|
||
<Image
|
||
src="/img/logo.png"
|
||
quality={100}
|
||
alt="log"
|
||
width={32}
|
||
height={32}
|
||
/>
|
||
<div className=" text-brown flex flex-col text-center w-40">
|
||
<h1 className="text-[21px] w-full">ســــــــوت زن</h1>
|
||
<h1 className="text-[9px]">سامانه افشار فساد شهرداری</h1>
|
||
</div>
|
||
</div>
|
||
<div className=" flex gap-5 items-center mr-8">
|
||
{menuItems.map((item, index, array) => {
|
||
if (array.length - 1 !== index) {
|
||
return (
|
||
<Link key={item.id} href={item.href}>
|
||
<div className=" text-sm font-bold">{item.name}</div>
|
||
</Link>
|
||
);
|
||
} else {
|
||
return <></>;
|
||
}
|
||
})}
|
||
</div>
|
||
</div>
|
||
{auth ? (
|
||
<ProfileDropDown />
|
||
) : (
|
||
<Link href="/Login">
|
||
<Button
|
||
onClick={() =>
|
||
localStorage.setItem("Sootzani_Login_State", "true")
|
||
}
|
||
className=" bg-blue hover:bg-blue/90 rounded-lg"
|
||
>
|
||
ورود به پنل کاربری
|
||
</Button>
|
||
</Link>
|
||
)}
|
||
</div>
|
||
</div>
|
||
);
|
||
}
|