"use client"; import Avatar from "boring-avatars"; import Link from "next/link"; import { useRouter } from "next/navigation"; import React, { useContext } from "react"; import { useLongPress } from "@uidotdev/usehooks"; import { toast } from "react-toastify"; import AppContext from "@ctx/AppContext"; import notifIcon from "@img/notif.png"; import Image from "next/image"; const AppHeader = ({ title, sub, icon1, iconName1, iconHref1, iconEvent1, icon2, iconName2, iconHref2, iconEvent2, iconName3, iconEvent3, userIcon, userIconData, userIconHref, userRole, logOut, notif, }) => { const router = useRouter(); const CTX = useContext(AppContext); const notifUnreadData = CTX.state.notifUnreadData; const handlelogOut = () => { CTX.setStepLogin(0); localStorage.removeItem("token"); router.push("/app/login"); }; const attrs = useLongPress(() => handlelogOut(), { // onStart: (event) => setSubButtonAction(true), onFinish: (event) => { handlelogOut(); }, // onCancel: (event) => setSubButtonAction(false), threshold: 1000, }); const icons = [ { iconName: "ACOUNT", icon: ( ), }, { iconName: "NINJA", icon: ( ), }, { iconName: "ARROW", icon: ( ), }, { iconName: "PLUS", icon: ( ), }, ]; // ; return (
{userIcon && (
)}

{title}

{sub}

{!userRole ? (
{logOut && (
{ toast.error(`برای خروج نگه دارید`, { position: "bottom-right", closeOnClick: true, }); }} >

خروج

)} {icon1 ? (
{icons.find((e) => e.iconName == iconName1)?.icon}
) : ( "" )} {icon2 ? (
{icons.find((e) => e.iconName == iconName2)?.icon}
) : ( "" )} {notif && ( {notifUnreadData > 0 && (
)} )}
) : (

{iconName3}

)}
); }; export default AppHeader;