fix condition login or logout
This commit is contained in:
@@ -15,9 +15,9 @@ import TelegramIcon from '../icons/TelegramIcon';
|
||||
import Modal from '../utils/Modal';
|
||||
import LogoutPrompt from '@/features/general/LogoutPrompt';
|
||||
import useToggle from '@/hooks/helpers/useToggle';
|
||||
import { useAuthStore } from '@/zustand/authStore';
|
||||
import { useGetAbout } from '@/app/[name]/(Main)/about/hooks/useAboutData';
|
||||
import Image from 'next/image';
|
||||
import { useGetProfile } from '@/app/[name]/(Profile)/profile/hooks/userProfileData';
|
||||
|
||||
type MenuItemType = {
|
||||
href: string | undefined;
|
||||
@@ -74,7 +74,6 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
|
||||
|
||||
const menuStateMemo = useMemo(() => menuState, [menuState]);
|
||||
const closeRef = useRef<HTMLDivElement>(null);
|
||||
const userIsAuthenticated = useAuthStore((state) => state.isAuthenticated);
|
||||
const { state: logoutModal, toggle: toggleLogoutModal } = useToggle();
|
||||
const { state: shareModal, toggle: toggleShareModal } = useToggle();
|
||||
const { state: installPwaModal, toggle: toggleInstallPwaModal } = useToggle();
|
||||
@@ -82,6 +81,7 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
|
||||
const [isIOSDevice, setIsIOSDevice] = useState(false);
|
||||
const [isPWAInstalled, setIsPWAInstalled] = useState(false);
|
||||
const { data: aboutData } = useGetAbout();
|
||||
const { isSuccess } = useGetProfile();
|
||||
|
||||
const params = useParams();
|
||||
const { name } = params;
|
||||
@@ -160,8 +160,8 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
|
||||
<ul>
|
||||
{menuItems[0]
|
||||
.filter(item => {
|
||||
if (item.auth && !userIsAuthenticated) return false;
|
||||
if (item.guestOnly && userIsAuthenticated) return false;
|
||||
if (item.auth && !isSuccess) return false;
|
||||
if (item.guestOnly && isSuccess) return false;
|
||||
if (item.href === '?installpwa' && isPWAInstalled) return false;
|
||||
return true;
|
||||
})
|
||||
@@ -199,8 +199,8 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
|
||||
<ul className="flex flex-col pt-16">
|
||||
{menuItems[2]
|
||||
.filter(item => {
|
||||
if (item.auth && !userIsAuthenticated) return false;
|
||||
if (item.guestOnly && userIsAuthenticated) return false;
|
||||
if (item.auth && !isSuccess) return false;
|
||||
if (item.guestOnly && isSuccess) return false;
|
||||
return true;
|
||||
})
|
||||
.map(({ icon: Icon, ...item }, index) => {
|
||||
|
||||
Reference in New Issue
Block a user