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:
25
customer-spa/src/hooks/useModuleSettings.ts
Normal file
25
customer-spa/src/hooks/useModuleSettings.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { api } from '@/lib/api/client';
|
||||
|
||||
interface ModuleSettings {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to fetch module settings
|
||||
*/
|
||||
export function useModuleSettings(moduleId: string) {
|
||||
const { data, isLoading } = useQuery<ModuleSettings>({
|
||||
queryKey: ['module-settings', moduleId],
|
||||
queryFn: async () => {
|
||||
const response = await api.get(`/modules/${moduleId}/settings`);
|
||||
return response || {};
|
||||
},
|
||||
staleTime: 5 * 60 * 1000, // Cache for 5 minutes
|
||||
});
|
||||
|
||||
return {
|
||||
settings: data || {},
|
||||
isLoading,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user