"use client" import Link from "next/link" import { usePathname } from "next/navigation" import { useState, useEffect } from "react" import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import Image from "next/image" const allNavItems = [ { href: "/", label: "ALL SPORTS" }, { href: "/live", label: "LIVE" }, { href: "/virtual", label: "VIRTUAL" }, { href: "/special-games", label: "SPECIAL Games" }, { href: "/multi-hot-5", label: "MULTI HOT 5" }, { href: "/poker", label: "POKER", isNew: true }, { href: "/race", label: "RACE", isNew: true }, { href: "/promo", label: "PROMO" }, { href: "/aviator", label: "AVIATOR" }, ] const drawerLinks = [ { href: "/", label: "All Sports" }, { href: "/live", label: "Live Betting" }, { href: "/virtual", label: "Virtual" }, { href: "/special-games", label: "Special Games" }, { href: "/poker", label: "Poker" }, { href: "/race", label: "Race" }, { href: "/promo", label: "Promotions" }, { href: "/deposit", label: "Deposit" }, { href: "/bonus", label: "Bonus" }, { href: "/rules", label: "Betting Rules" }, { href: "/terms", label: "Terms & Conditions" }, ] interface SiteHeaderProps { onLoginClick?: () => void onRegisterClick?: () => void } export function SiteHeader({ onLoginClick, onRegisterClick }: SiteHeaderProps) { const pathname = usePathname() const isLivePage = pathname === "/live" const [time, setTime] = useState("") const [prevPathname, setPrevPathname] = useState(pathname) const [drawerOpen, setDrawerOpen] = useState(false) // Adjust state during render when pathname changes if (pathname !== prevPathname) { setPrevPathname(pathname) setDrawerOpen(false) } useEffect(() => { const updateClock = () => { setTime(new Date().toLocaleTimeString("en-GB", { hour12: false })) } const interval = setInterval(updateClock, 1000) updateClock() return () => clearInterval(interval) }, []) return ( <>
{/* ===== DESKTOP: Top bar (hidden on mobile) ===== */}
🕒 {time || "00:00:00"}
+251 (0)
{/* ===== MOBILE: Top bar (hidden on desktop) ===== */}
{/* Hamburger */} {/* Logo (centered, grows to fill) */}
HARIF
SPORT
{/* LOGIN / SIGN UP */}
{/* ===== DESKTOP: Main header bar ===== */}
HARIF
SPORT
{/* ===== MOBILE: Horizontally scrollable nav tabs ===== */}
{allNavItems.map((item) => { const isActive = pathname === item.href return ( {item.isNew && ( NEW )} {item.label} ) })}
{/* ===== MOBILE: Sport Category Icons Row ===== */}
{[ { label: "Check Bet", icon: (active: boolean) => , count: 99 }, { label: "Live", icon: (active: boolean) =>
, count: 1247 }, { label: "Football", icon: (active: boolean) => , count: 95 }, { label: "Tennis", icon: (active: boolean) => , count: 384 }, { label: "Basketball", icon: (active: boolean) => , count: 173 }, ].map((item, idx) => (
{item.count}
{typeof item.icon === 'function' ? item.icon(false) : item.icon}
{item.label}
))}
{/* ===== DESKTOP: Secondary sub-header ===== */} {pathname !== "/virtual" && pathname !== "/special-games" && (
{[ { label: "Sport Home", href: "/" }, { label: "Live View", href: "/live", forceActive: isLivePage }, ].map((tab) => { const isActive = tab.forceActive || pathname === tab.href return ( {tab.label} {isActive && tab.label !== "Sport Home" && (
)} ) })}
)}
{/* ===== MOBILE Drawer ===== */} {drawerOpen && (
{/* Backdrop */}
setDrawerOpen(false)} /> {/* Drawer panel */}
{/* Drawer header */}
HARIF
SPORT
{/* Nav links */}
)} ) }