refactor(ui): restructure sidebar and admin navigation
- Sidebar: remove footer (user info, settings, locale switcher), remove admin section, make category headers static with per-category collapse toggle - Header dropdown: replace inline admin links with single "Administrator" entry - Admin section: dedicated layout with AdminSidebar (mirrors Settings pattern) at /admin/* - Disable self-delete button in user management (backend already rejects with 403) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ import { useSidebarStore } from '@/lib/stores/sidebar-store';
|
||||
import { useAuthStore } from '@/lib/stores/auth-store';
|
||||
import { fetchCurrentUser, logout } from '@/lib/auth-actions';
|
||||
import { ThemeToggle } from '@/components/theme-toggle';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
export function Header() {
|
||||
const t = useTranslations();
|
||||
@@ -15,6 +16,9 @@ export function Header() {
|
||||
const { user, setUser } = useAuthStore();
|
||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||
const dropdownRef = useRef<HTMLDivElement>(null);
|
||||
const pathname = usePathname();
|
||||
|
||||
const isAdmin = user?.role === 'ADMIN' || user?.role === 'SUPER_ADMIN';
|
||||
|
||||
// Fetch current user on mount to populate auth store
|
||||
useEffect(() => {
|
||||
@@ -154,7 +158,28 @@ export function Header() {
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
{/* Administration link */}
|
||||
{isAdmin && (
|
||||
<div className="px-2 py-1">
|
||||
<Link
|
||||
href="/admin/users"
|
||||
onClick={() => setDropdownOpen(false)}
|
||||
className={`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors ${
|
||||
pathname.startsWith('/admin')
|
||||
? 'bg-muted text-foreground font-medium'
|
||||
: 'text-foreground hover:bg-muted'
|
||||
}`}
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
||||
<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z" />
|
||||
</svg>
|
||||
{tHeader('admin.label')}
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Logout button */}
|
||||
<div className="border-t border-border my-1" />
|
||||
<div className="px-2 py-1">
|
||||
<button
|
||||
onClick={() => {
|
||||
|
||||
Reference in New Issue
Block a user