fix: Dashboard always active + Full wishlist settings implementation
Dashboard Navigation Fix: - Fixed ActiveNavLink to only activate Dashboard on / or /dashboard/* paths - Dashboard no longer shows active when on other routes (Marketing, Settings, etc.) - Proper path matching logic for all main menu items Wishlist Settings - Full Implementation: Backend (PHP): 1. Guest Wishlist Support - Modified check_permission() to allow guests if enable_guest_wishlist is true - Guests can now add/remove wishlist items (stored in user meta when they log in) 2. Max Items Limit - Added max_items_per_wishlist enforcement in add_to_wishlist() - Returns error when limit reached with helpful message - 0 = unlimited (default) Frontend (React): 3. Show in Header Setting - Added useModuleSettings hook to customer-spa - Wishlist icon respects show_in_header setting (default: true) - Icon hidden when setting is false 4. Show Add to Cart Button Setting - Wishlist page checks show_add_to_cart_button setting - Add to cart buttons hidden when setting is false (default: true) - Allows wishlist-only mode without purchase prompts Files Added (1): - customer-spa/src/hooks/useModuleSettings.ts Files Modified (5): - admin-spa/src/App.tsx (dashboard active fix) - includes/Frontend/WishlistController.php (guest support, max items) - customer-spa/src/layouts/BaseLayout.tsx (show_in_header) - customer-spa/src/pages/Account/Wishlist.tsx (show_add_to_cart_button) - admin-spa/dist/app.js + customer-spa/dist/app.js (rebuilt) Implemented Settings (4 of 8): ✅ enable_guest_wishlist - Backend permission check ✅ show_in_header - Frontend icon visibility ✅ max_items_per_wishlist - Backend validation ✅ show_add_to_cart_button - Frontend button visibility Not Yet Implemented (4 of 8): - wishlist_page (page selector - would need routing logic) - enable_sharing (share functionality - needs share UI) - enable_email_notifications (back in stock - needs cron job) - enable_multiple_wishlists (multiple lists - needs data structure change) All core wishlist settings now functional!
This commit is contained in:
@@ -8,6 +8,7 @@ import { SearchModal } from '../components/SearchModal';
|
||||
import { NewsletterForm } from '../components/NewsletterForm';
|
||||
import { LayoutWrapper } from './LayoutWrapper';
|
||||
import { useModules } from '../hooks/useModules';
|
||||
import { useModuleSettings } from '../hooks/useModuleSettings';
|
||||
|
||||
interface BaseLayoutProps {
|
||||
children: ReactNode;
|
||||
@@ -48,6 +49,7 @@ function ClassicLayout({ children }: BaseLayoutProps) {
|
||||
const user = (window as any).woonoowCustomer?.user;
|
||||
const headerSettings = useHeaderSettings();
|
||||
const { isEnabled } = useModules();
|
||||
const { settings: wishlistSettings } = useModuleSettings('wishlist');
|
||||
const footerSettings = useFooterSettings();
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [searchOpen, setSearchOpen] = useState(false);
|
||||
@@ -133,7 +135,7 @@ function ClassicLayout({ children }: BaseLayoutProps) {
|
||||
))}
|
||||
|
||||
{/* Wishlist */}
|
||||
{headerSettings.elements.wishlist && isEnabled('wishlist') && user?.isLoggedIn && (
|
||||
{headerSettings.elements.wishlist && isEnabled('wishlist') && (wishlistSettings.show_in_header ?? true) && user?.isLoggedIn && (
|
||||
<Link to="/my-account/wishlist" className="flex items-center gap-2 text-sm font-medium text-gray-700 hover:text-gray-900 transition-colors no-underline">
|
||||
<Heart className="h-5 w-5" />
|
||||
<span className="hidden lg:block">Wishlist</span>
|
||||
|
||||
Reference in New Issue
Block a user