fix: Navigation issues - newsletter menu, coupon routing, module toggle
Navigation Fixes:
1. Newsletter submenu now hidden when module disabled
- NavigationRegistry checks ModuleRegistry::is_enabled('newsletter')
- Menu updates dynamically based on module status
2. Module toggle now updates navigation in real-time
- Fixed toggle_module API to return success response (was returning error)
- Navigation cache flushes and rebuilds when module toggled
- Newsletter menu appears/disappears immediately after toggle
3. Coupon routes now activate Marketing menu (not Dashboard)
- Added special case in useActiveSection for /coupons paths
- Marketing menu stays active when viewing coupons
- Submenu shows correct Marketing items (Newsletter, Coupons)
4. Dashboard menu no longer always shows active
- Fixed by proper path matching in useActiveSection
- Only active when on dashboard routes
Files Modified (4):
- includes/Compat/NavigationRegistry.php (already had newsletter check, added rebuild on flush)
- includes/Api/ModulesController.php (fixed toggle_module response)
- admin-spa/src/hooks/useActiveSection.ts (added /coupons special case)
- admin-spa/dist/app.js (rebuilt)
All 4 navigation issues resolved!
This commit is contained in:
@@ -11,6 +11,12 @@ export function useActiveSection(): { main: MainNode; all: MainNode[] } {
|
||||
if (settingsNode) return settingsNode;
|
||||
}
|
||||
|
||||
// Special case: /coupons should match marketing section
|
||||
if (pathname === '/coupons' || pathname.startsWith('/coupons/')) {
|
||||
const marketingNode = navTree.find(n => n.key === 'marketing');
|
||||
if (marketingNode) return marketingNode;
|
||||
}
|
||||
|
||||
// Try to find section by matching path prefix
|
||||
for (const node of navTree) {
|
||||
if (node.path === '/') continue; // Skip dashboard for now
|
||||
|
||||
Reference in New Issue
Block a user