s
This commit is contained in:
@@ -29,10 +29,12 @@ export default memo(function SiteMenu({
|
||||
const { t } = useTranslation("menu");
|
||||
const pathname = usePathname();
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
const [userEmail, setUserEmail] = useState<string | null>(null);
|
||||
const [userEmail, setUserEmail] = useState<string | null>(() => getStoredUserEmail());
|
||||
|
||||
useEffect(() => {
|
||||
setUserEmail(getStoredUserEmail());
|
||||
const onAuthUpdated = () => setUserEmail(getStoredUserEmail());
|
||||
window.addEventListener("auth:updated", onAuthUpdated);
|
||||
return () => window.removeEventListener("auth:updated", onAuthUpdated);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -94,8 +96,8 @@ export default memo(function SiteMenu({
|
||||
];
|
||||
|
||||
const profileItems: MenuItem[] = [
|
||||
{ labelKey: "yourProfile", href: "/join", icon: "👤" },
|
||||
{ labelKey: "settings", href: "/join", icon: "⚙️" },
|
||||
{ labelKey: "yourProfile", href: "/digital/profile", icon: "👤" },
|
||||
{ labelKey: "settings", href: "/settings/notifications", icon: "⚙️" },
|
||||
{ labelKey: "favorites", href: "/", icon: "❤️" },
|
||||
{ labelKey: "pricing", href: "/pricing", icon: "👑" },
|
||||
{ labelKey: "nomadInsurance", href: "#", icon: "🛡️", ad: true },
|
||||
@@ -196,11 +198,12 @@ export default memo(function SiteMenu({
|
||||
</div>
|
||||
|
||||
{/* Footer */}
|
||||
{userEmail && (
|
||||
<div className="p-4 border-t border-gray-100 dark:border-gray-800">
|
||||
<div className="p-4 border-t border-gray-100 dark:border-gray-800">
|
||||
{userEmail ? (
|
||||
<button
|
||||
onClick={() => {
|
||||
pbLogout();
|
||||
setUserEmail(null);
|
||||
onClose();
|
||||
}}
|
||||
className="flex items-center gap-2 w-full px-3 py-2 rounded-lg text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 transition-colors"
|
||||
@@ -208,8 +211,19 @@ export default memo(function SiteMenu({
|
||||
<span>🚪</span>
|
||||
<span>{t("logout")}</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
) : (
|
||||
<button
|
||||
onClick={() => {
|
||||
onLoginClick();
|
||||
onClose();
|
||||
}}
|
||||
className="flex items-center gap-2 w-full px-3 py-2 rounded-lg text-sm text-[#ff4d4f] hover:bg-[#ff4d4f]/10 transition-colors"
|
||||
>
|
||||
<span>👤</span>
|
||||
<span>{t("login")}</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user