"use client"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { Dispatch, SetStateAction, useMemo, useState } from "react"; import { FaRegUserCircle } from "react-icons/fa"; import { Currency } from "@appTypes/StoreModel"; import AuthModal from "@components/AuthModal"; import { useStoreActions, useStoreState } from "@hooks/store"; function NavbarButton({ name, href, dropdownItems }: { name: string; href: string; dropdownItems?: string[] }) { const pathname = usePathname(); const isActive = dropdownItems ? dropdownItems.some((item) => pathname === `/${item.toLowerCase().replace(" ", "-")}`) : pathname === href; return ( {dropdownItems ? ( {name} ) : ( {name} )} {dropdownItems && ( {dropdownItems.map((item) => { const itemHref = `/${item.toLowerCase().replace(" ", "-")}`; const isDropdownActive = pathname === itemHref; return ( {item} ); })} )} ); } export default function Navbar({}: // currencySelector, { // currencySelector?: { selectedCurrency: string; setSelectedCurrency: Dispatch> }; }) { const pathname = usePathname(); const selectedCurrency = useStoreState((state) => state.currency.selectedCurrency); const setSelectedCurrency = useStoreActions((actions) => actions.currency.setSelectedCurrency); const navOptions = useMemo(() => ["Earthquakes", "Observatories", "Warehouse", "Shop"], []); // const navOptions = useMemo(() => ["Earthquakes"], []); const aboutDropdown = ["Contact Us", "Our Mission", "The Team"]; // { label: "Our Mission", path: "/our-mission" }, // { label: "The Team", path: "/the-team" }, // { label: "Contact Us", path: "/contact-us" }] const [isModalOpen, setIsModalOpen] = useState(false); const currencies = useStoreState((state) => state.currency.currencies); const currencyTickers = useStoreState((state) => state.currency.tickers); return ( {navOptions.map((name) => ( ))} {pathname.includes("shop") && ( {selectedCurrency} {currencies.map((item) => { let ticker = currencyTickers[item]; return ( setSelectedCurrency(item)}> {`${item} (${ticker})`} ); })} )} setIsModalOpen(true)}> setIsModalOpen(false)} /> ); }