"use client"; import { useAuth } from "@/lib/auth-context"; import { SHOP_INFO } from "@/lib/constants"; import { useManager } from "@/lib/manager-context"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/navigation"; /** * Site Header — sticky top bar, always visible on all screen sizes. * * 2-column layout: * [LEFT: Brand (logo + name + tagline)] | [RIGHT: Auth button] * * Auth states: * - Guest: Shows "Đăng nhập" button → navigates to /login * - Manager: Shows "Quản lý" badge with logout on click * - Staff: Shows staff name with logout on click * - Customer: Shows "Khách hàng" with phone and logout on click * * Responsive: * - Logo + shop name : always visible * - Tagline : hidden on mobile (< md), shown on md+ * - Button label : hidden on xs (< sm), shown on sm+ */ export default function Header() { const router = useRouter(); const { eatery } = useManager(); const { user, logout } = useAuth(); const handleAuthClick = () => { if (!user) { router.push("/login"); } else { logout(); } }; return (
{/* ── LEFT: Brand ── */} {/* Logo */}
{`${eatery?.name}
{/* Name + tagline */}
{eatery?.name} {SHOP_INFO.tagline}
{/* ── RIGHT: Auth ── */}
{!user ? ( /* Guest: sign-in button */ ) : user.role === "manager" ? ( /* Manager: dashboard link + logout */
Dashboard
) : user.role === "staff" ? ( /* Staff: Register shift + avatar + name */
My Shifts
) : ( /* Customer: phone icon + label */ )}
); }