bulk cart

This commit is contained in:
hamid zarghami
2025-12-01 10:33:22 +03:30
parent 788d23b185
commit b4b900cfc1
8 changed files with 83 additions and 11 deletions
+17 -5
View File
@@ -10,17 +10,19 @@ import Button from '../button/PrimaryButton';
import { useParams, usePathname } from 'next/navigation';
import clsx from 'clsx';
import { useTranslation } from 'react-i18next';
import { CalendarSearch, Cup, DirectboxReceive, DirectInbox, DocumentCopy, Game, Icon, Instagram, Like1, LogoutCurve, Notification, Receipt1, Setting2, Share, TicketDiscount, Whatsapp } from 'iconsax-react';
import { CalendarSearch, Cup, DirectboxReceive, DirectInbox, DocumentCopy, Game, Icon, Instagram, Like1, Login, LogoutCurve, Notification, Receipt1, Setting2, Share, TicketDiscount, Whatsapp } from 'iconsax-react';
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';
type MenuItemType = {
href: string | undefined;
title: string;
icon: Icon;
auth?: boolean;
guestOnly?: boolean;
};
const menuItems: Array<Array<MenuItemType>> = [
@@ -38,7 +40,8 @@ const menuItems: Array<Array<MenuItemType>> = [
[],
[
{ auth: true, href: 'profile/settings', title: 'Preferences', icon: Setting2 },
{ auth: true, href: '?logout', title: 'Logout', icon: LogoutCurve }
{ auth: true, href: '?logout', title: 'Logout', icon: LogoutCurve },
{ guestOnly: true, href: 'auth', title: 'LoginSignup', icon: Login }
]
];
@@ -52,7 +55,7 @@ type Props = {
function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeState }: Props) {
const menuStateMemo = useMemo(() => menuState, [menuState]);
const closeRef = useRef<HTMLDivElement>(null);
const userIsAuthenticated = true; // useAuthStore((state) => state.isAuthenticated);
const userIsAuthenticated = useAuthStore((state) => state.isAuthenticated);
const { state: logoutModal, toggle: toggleLogoutModal } = useToggle();
const { state: shareModal, toggle: toggleShareModal } = useToggle();
const { state: installPwaModal, toggle: toggleInstallPwaModal } = useToggle();
@@ -92,7 +95,11 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
<nav aria-label={tMenu('NavAriaLabel')}>
<ul>
{menuItems[0]
.filter(item => !item.auth || (item.auth && userIsAuthenticated))
.filter(item => {
if (item.auth && !userIsAuthenticated) return false;
if (item.guestOnly && userIsAuthenticated) return false;
return true;
})
.map(({ icon: Icon, ...item }, index) => {
const href = `/${name}/${item.href}`;
const isActive = pathname === href;
@@ -126,7 +133,11 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
<section aria-label={tMenu('ControlsAriaLabel')}>
<ul className="flex flex-col pt-16">
{menuItems[2]
.filter(item => !item.auth || (item.auth && userIsAuthenticated))
.filter(item => {
if (item.auth && !userIsAuthenticated) return false;
if (item.guestOnly && userIsAuthenticated) return false;
return true;
})
.map(({ icon: Icon, ...item }, index) => {
const href = `/${name}/${item.href}`;
const isActive = pathname === href;
@@ -203,6 +214,7 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
<LogoutPrompt
visible={logoutModal}
onClick={toggleLogoutModal}
slug={name as string}
/>
{/* Share modal */}