"use client"; import { useEffect, useRef, useState } from "react"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { CUSTOMER_PORTAL_URL, ADMIN_DASHBOARD_URL } from "@/lib/meshkee"; import { useMeshkeeSession, isAdminUser } from "@/lib/auth-client"; import styles from "./Header.module.css"; const NAV = [ { href: "/services", label: "خدمات کلینیک" }, { href: "/blog", label: "مقالات" }, { href: "/virtual-tour", label: "تور مجازی" }, { href: "/about-us", label: "درباره ما" }, { href: "/contact-us", label: "تماس با ما" }, ]; const CLINIC_PHONE_LABEL = "۰۲۵ - ۳۲۹۴۵۰۷۷"; const CLINIC_PHONE_TEL = "tel:+982532945077"; function PhoneIcon() { return ( ); } function UserIcon() { return ( ); } function ChevronIcon() { return ( ); } function userDisplayName(user) { return ( user?.firstName || user?.name || user?.fullName || (user?.cellNumber ? user.cellNumber : "کاربر") ); } function AccountMenu() { const { status, user, logout } = useMeshkeeSession(); const [open, setOpen] = useState(false); const rootRef = useRef(null); useEffect(() => { if (!open) return; const onDocClick = (e) => { if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(false); }; document.addEventListener("mousedown", onDocClick); return () => document.removeEventListener("mousedown", onDocClick); }, [open]); if (status !== "in") { // Signed out (or still loading): the icon just sends the shopper to // the customer account portal to sign in / register. return ( ); } const admin = isAdminUser(user); return (
{open ? (
پروفایل من {admin ? ( مدیریت وبسایت ) : null}
) : null}
); } export default function Header() { const pathname = usePathname(); const [open, setOpen] = useState(false); const [scrolled, setScrolled] = useState(false); useEffect(() => { const onScroll = () => setScrolled(window.scrollY > 20); onScroll(); window.addEventListener("scroll", onScroll, { passive: true }); return () => window.removeEventListener("scroll", onScroll); }, []); useEffect(() => { setOpen(false); }, [pathname]); return (
کلینیک دندانپزشکی نگین
{CLINIC_PHONE_LABEL}
); }