fix(admin): refresh sidebar after module toggle on admin page
Activating/deactivating a module from the admin modules page updated only the page's local state — the sidebar (which refetches its active-module list on the shared marketplace-store sidebarRefreshKey signal) was never bumped, so the module's nav link only appeared/disappeared after a manual full page reload. The marketplace pages already call bumpSidebarRefresh() after a toggle; mirror that here. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useAuthStore } from '@/lib/stores/auth-store';
|
||||
import { useMarketplaceStore } from '@/lib/stores/marketplace-store';
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001';
|
||||
|
||||
@@ -27,6 +28,11 @@ export default function AdminModulesPage() {
|
||||
const t = useTranslations('adminModules');
|
||||
const tCommon = useTranslations('common');
|
||||
const currentUser = useAuthStore((s) => s.user);
|
||||
// Shared signal that makes the sidebar refetch its active-module list
|
||||
// (same mechanism the marketplace pages use). Without bumping this after a
|
||||
// toggle here, an activation from the admin page only updates local state —
|
||||
// the sidebar link would not appear until a full page reload.
|
||||
const bumpSidebarRefresh = useMarketplaceStore((s) => s.bumpSidebarRefresh);
|
||||
|
||||
const [modules, setModules] = useState<Module[]>([]);
|
||||
const [activations, setActivations] = useState<Map<string, boolean>>(new Map());
|
||||
@@ -91,6 +97,9 @@ export default function AdminModulesPage() {
|
||||
}
|
||||
return next;
|
||||
});
|
||||
// Refresh the sidebar so the (de)activated module's link appears/
|
||||
// disappears immediately, without a manual full page reload.
|
||||
bumpSidebarRefresh();
|
||||
} else {
|
||||
const body = await res.text().catch(() => '');
|
||||
setError(`${res.status}: ${body}`);
|
||||
|
||||
Reference in New Issue
Block a user