This commit is contained in:
eric
2026-03-09 05:07:59 -05:00
parent 302a072036
commit eb852fb11d
27 changed files with 1523 additions and 169 deletions

View File

@@ -1,9 +1,8 @@
"use client";
import { memo, useState, useEffect, useRef } from "react";
import { memo, useEffect, useRef, useState } from "react";
import { Link, usePathname, useTranslation } from "@/i18n/navigation";
import { getStoredUserEmail, pbLogout } from "@/app/lib/pocketbase";
import ThemeToggle from "./ThemeToggle";
interface MenuItem {
labelKey: string;
@@ -30,7 +29,6 @@ export default memo(function SiteMenu({
const { t } = useTranslation("menu");
const pathname = usePathname();
const ref = useRef<HTMLDivElement>(null);
const [search, setSearch] = useState("");
const [userEmail, setUserEmail] = useState<string | null>(null);
useEffect(() => {
@@ -58,32 +56,27 @@ export default memo(function SiteMenu({
{
titleKey: "community",
items: [
{ labelKey: "dating", href: "/dating", icon: "❤️" },
{ labelKey: "chat", href: "/join", icon: "💬" },
{ labelKey: "hostMeetup", href: "/meetups", icon: "🎤", new: true },
{ labelKey: "friendFinder", href: "/dating", icon: "💛" },
{ labelKey: "membersMap", href: "#", icon: "🌐" },
{ labelKey: "attendMeetup", href: "/meetups", icon: "🍹" },
{ labelKey: "hostMeetup", href: "/meetups/host", icon: "🎤", new: true },
{ labelKey: "membersMap", href: "/map", icon: "🌐" },
],
},
{
titleKey: "tools",
items: [
{ labelKey: "explore", href: "/", icon: "📍" },
{ labelKey: "nextStop", href: "/dashboard", icon: "🗺️" },
{ labelKey: "climateFinder", href: "/tools", icon: "🌤️" },
{ labelKey: "fireCalculator", href: "/tools", icon: "🌱" },
{ labelKey: "costCalculator", href: "/tools", icon: "💱" },
{ labelKey: "aiAssistant", href: "/ai", icon: "🤖", new: true },
{ labelKey: "yearInReview", href: "/report", icon: "🥂" },
{ labelKey: "nomadStats", href: "/report", icon: "📊", new: true },
{ labelKey: "nomadStats", href: "/report/data", icon: "📊", new: true },
{ labelKey: "gigBoard", href: "/gigs", icon: "💰" },
{ labelKey: "costCalculator", href: "/tools", icon: "💱" },
],
},
{
titleKey: "help",
items: [
{ labelKey: "ideasBugs", href: "#", icon: "💡" },
{ labelKey: "ideasBugs", href: "/feedback", icon: "💡" },
{ labelKey: "faq", href: "#", icon: "🆘" },
{ labelKey: "terms", href: "#", icon: "📄" },
{ labelKey: "changelog", href: "#", icon: "🚀" },
@@ -106,14 +99,7 @@ export default memo(function SiteMenu({
{ labelKey: "nomadInsurance", href: "#", icon: "🛡️", ad: true },
];
const filteredSections = sections.map((sec) => ({
...sec,
items: search
? sec.items.filter((i) =>
t(i.labelKey).toLowerCase().includes(search.toLowerCase())
)
: sec.items,
})).filter((sec) => sec.items.length > 0);
const filteredSections = sections;
if (!isOpen) return null;
@@ -124,59 +110,7 @@ export default memo(function SiteMenu({
ref={ref}
className="fixed left-4 right-4 top-20 md:left-auto md:right-4 md:top-16 md:w-[480px] z-50 rounded-2xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 shadow-2xl overflow-hidden"
>
{/* Header */}
<div className="p-4 border-b border-gray-100 dark:border-gray-800 space-y-3">
<div className="flex items-center gap-2">
{userEmail ? (
<div className="flex items-center gap-2 flex-1 min-w-0">
<div className="w-9 h-9 rounded-full bg-gradient-to-br from-[#ff4d4f] to-orange-500 flex items-center justify-center text-white text-sm font-bold shrink-0">
{userEmail[0].toUpperCase()}
</div>
<span className="text-sm font-medium text-gray-900 dark:text-gray-100 truncate">
{userEmail}
</span>
</div>
) : (
<button
onClick={onLoginClick}
className="px-4 py-2 rounded-lg bg-[#ff4d4f] text-white text-sm font-medium hover:bg-[#ff3333] transition-colors"
>
{t("login")}
</button>
)}
<Link
href="/dashboard"
onClick={onClose}
className="px-4 py-2 rounded-lg bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 text-sm font-medium hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors"
>
{t("filters")}
</Link>
<Link
href="/join"
onClick={onClose}
className="w-9 h-9 rounded-full bg-[#ff4d4f] text-white flex items-center justify-center hover:bg-[#ff3333] transition-colors shrink-0"
aria-label={t("add")}
>
<svg className="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" />
</svg>
</Link>
</div>
<div className="relative">
<svg className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
<input
type="text"
value={search}
onChange={(e) => setSearch(e.target.value)}
placeholder={t("searchPlaceholder")}
className="w-full pl-10 pr-4 py-2.5 rounded-xl border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800 text-gray-900 dark:text-gray-100 placeholder-gray-400 text-sm focus:outline-none focus:ring-2 focus:ring-[#ff4d4f]/20 focus:border-[#ff4d4f]"
/>
</div>
</div>
{/* Profile + Dark mode */}
{/* Profile links */}
<div className="px-4 py-3 border-b border-gray-100 dark:border-gray-800 flex flex-wrap items-center gap-2">
{profileItems.map((item) => (
<Link
@@ -189,10 +123,6 @@ export default memo(function SiteMenu({
<span>{t(item.labelKey)}</span>
</Link>
))}
<div className="ml-auto flex items-center gap-2">
<span className="text-xs text-gray-500 dark:text-gray-400">{t("darkMode")}</span>
<ThemeToggle />
</div>
</div>
{/* Sections */}