"use client"; import { motion, AnimatePresence } from "framer-motion"; import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { Sun, Moon, ArrowLeft } from "lucide-react"; import { useTheme } from "@/app/lib/ThemeContext"; import TastefullyLogo from "@/app/components/TastefullyLogo"; const EXACT_SUB_PAGES: Record = { "/store/history": "Points History", "/settings/profile": "My Profile", "/settings/change-password": "Change Password", "/settings/transactions": "Transactions", "/settings/referral": "Referral", // Pages opened from a Home tile: back arrow + title, never the logo (TASTE-148). "/draw": "Lucky Draw", "/attendance": "Attendance", "/goodie-bag": "Welcome Gift", "/stage": "Stage", "/floorplan": "Floor Plan", }; function getSubTitle(pathname: string): string | null { if (pathname in EXACT_SUB_PAGES) return EXACT_SUB_PAGES[pathname]; return null; } const AUTH_PATHS = new Set(["/login", "/register", "/forgot-password", "/register/verify", "/reset-password"]); export default function AppHeader() { const pathname = usePathname(); const router = useRouter(); const { isDark, toggle } = useTheme(); if (AUTH_PATHS.has(pathname)) return null; const subTitle = getSubTitle(pathname); const isSubPage = Boolean(subTitle); const borderColor = isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.06)"; const cardBg = isDark ? "rgba(255,255,255,0.05)" : "rgba(0,0,0,0.04)"; const cardBorder = isDark ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.07)"; const cardShadow = isDark ? "0 1px 6px rgba(0,0,0,0.25)" : "0 1px 4px rgba(0,0,0,0.05)"; const textColor = isDark ? "#FFFFFF" : "#1a1a1a"; const textSec = isDark ? "rgba(255,255,255,0.8)" : "#5C5C5C"; return (
{/* Left — logo or back + title */} {isSubPage ? ( router.back()} aria-label="Back" whileTap={{ scale: 0.88 }} transition={{ type: "spring", stiffness: 420, damping: 24 }} className="w-8 h-8 rounded-xl flex items-center justify-center" style={{ background: cardBg, border: `1px solid ${cardBorder}`, boxShadow: cardShadow }} > {subTitle} ) : ( )} {/* Right — theme toggle (always present) */} {isDark ? ( ) : ( )}
); }