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